[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:44:07 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=dc6cd4c

The following commit has been merged in the master branch:
commit dc6cd4cf671f06ca7185eb52f0a1e92415f58af3
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Fri Jan 17 10:23:30 2014 +0000

    #945: Set the makernote 'state' before post-processing Makernote components during reading.
---
 src/tiffimage.cpp       |  3 +--
 src/tiffvisitor.cpp     | 43 +++++++++++++++++++++++--------------------
 src/tiffvisitor_int.hpp | 26 ++++++++++++++------------
 3 files changed, 38 insertions(+), 34 deletions(-)

diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp
index 296d951..cb85835 100644
--- a/src/tiffimage.cpp
+++ b/src/tiffimage.cpp
@@ -1949,8 +1949,7 @@ namespace Exiv2 {
         TiffComponent::AutoPtr rootDir = TiffCreator::create(root, ifdIdNotSet);
         if (0 != rootDir.get()) {
             rootDir->setStart(pData + pHeader->offset());
-            TiffRwState::AutoPtr state(
-                new TiffRwState(pHeader->byteOrder(), 0));
+            TiffRwState state(pHeader->byteOrder(), 0);
             TiffReader reader(pData, size, rootDir.get(), state);
             rootDir->accept(reader);
             reader.postProcess();
diff --git a/src/tiffvisitor.cpp b/src/tiffvisitor.cpp
index 6bd076d..43ef0e7 100644
--- a/src/tiffvisitor.cpp
+++ b/src/tiffvisitor.cpp
@@ -1135,15 +1135,16 @@ namespace Exiv2 {
     TiffReader::TiffReader(const byte*    pData,
                            uint32_t       size,
                            TiffComponent* pRoot,
-                           TiffRwState::AutoPtr state)
+                           TiffRwState    state)
         : pData_(pData),
           size_(size),
           pLast_(pData + size),
           pRoot_(pRoot),
-          pState_(state.release()),
-          pOrigState_(pState_),
+          origState_(state),
+          mnState_(state),
           postProc_(false)
     {
+        pState_ = &origState_;
         assert(pData_);
         assert(size_ > 0);
 
@@ -1151,35 +1152,37 @@ namespace Exiv2 {
 
     TiffReader::~TiffReader()
     {
-        if (pOrigState_ != pState_) delete pOrigState_;
-        delete pState_;
     }
 
-    void TiffReader::resetState() {
-        if (pOrigState_ != pState_) delete pState_;
-        pState_ = pOrigState_;
+    void TiffReader::setOrigState()
+    {
+        pState_ = &origState_;
     }
 
-    void TiffReader::changeState(TiffRwState::AutoPtr state)
+    void TiffReader::setMnState(const TiffRwState* state)
     {
-        if (state.get() != 0) {
+        if (state != 0) {
             // invalidByteOrder indicates 'no change'
-            if (state->byteOrder_ == invalidByteOrder) state->byteOrder_ = pState_->byteOrder_;
-            if (pOrigState_ != pState_) delete pState_;
-            pState_ = state.release();
+            if (state->byteOrder() == invalidByteOrder) {
+                mnState_ = TiffRwState(origState_.byteOrder(), state->baseOffset());
+            }
+            else {
+                mnState_ = *state;
+            }
         }
+        pState_ = &mnState_;
     }
 
     ByteOrder TiffReader::byteOrder() const
     {
         assert(pState_);
-        return pState_->byteOrder_;
+        return pState_->byteOrder();
     }
 
     uint32_t TiffReader::baseOffset() const
     {
         assert(pState_);
-        return pState_->baseOffset_;
+        return pState_->baseOffset();
     }
 
     void TiffReader::readDataEntryBase(TiffDataEntryBase* object)
@@ -1244,11 +1247,13 @@ namespace Exiv2 {
 
     void TiffReader::postProcess()
     {
+        setMnState(); // All components to be post-processed must be from the Makernote
         postProc_ = true;
         for (PostList::const_iterator pos = postList_.begin(); pos != postList_.end(); ++pos) {
             (*pos)->accept(*this);
         }
         postProc_ = false;
+        setOrigState();
     }
 
     void TiffReader::visitDirectory(TiffDirectory* object)
@@ -1432,17 +1437,15 @@ namespace Exiv2 {
 
         // Modify reader for Makernote peculiarities, byte order and offset
         object->mnOffset_ = static_cast<uint32_t>(object->start() - pData_);
-        TiffRwState::AutoPtr state(
-            new TiffRwState(object->byteOrder(), object->baseOffset())
-        );
-        changeState(state);
+        TiffRwState state(object->byteOrder(), object->baseOffset());
+        setMnState(&state);
 
     } // TiffReader::visitIfdMakernote
 
     void TiffReader::visitIfdMakernoteEnd(TiffIfdMakernote* /*object*/)
     {
         // Reset state (byte order, create function, offset) back to that for the image
-        resetState();
+        setOrigState();
     } // TiffReader::visitIfdMakernoteEnd
 
     void TiffReader::readTiffEntry(TiffEntryBase* object)
diff --git a/src/tiffvisitor_int.hpp b/src/tiffvisitor_int.hpp
index bda1af6..77044b6 100644
--- a/src/tiffvisitor_int.hpp
+++ b/src/tiffvisitor_int.hpp
@@ -586,11 +586,7 @@ namespace Exiv2 {
              makernotes).
      */
     class TiffRwState {
-        friend class TiffReader;
     public:
-        //! TiffRWState auto_ptr type
-        typedef std::auto_ptr<TiffRwState> AutoPtr;
-
         //! @name Creators
         //@{
         //! Constructor.
@@ -623,7 +619,7 @@ namespace Exiv2 {
 
     private:
         ByteOrder byteOrder_;
-        const uint32_t baseOffset_;
+        uint32_t  baseOffset_;
     }; // TiffRwState
 
     /*!
@@ -647,7 +643,7 @@ namespace Exiv2 {
         TiffReader(const byte*          pData,
                    uint32_t             size,
                    TiffComponent*       pRoot,
-                   TiffRwState::AutoPtr state);
+                   TiffRwState          state);
 
         //! Virtual destructor
         virtual ~TiffReader();
@@ -682,10 +678,15 @@ namespace Exiv2 {
         void readTiffEntry(TiffEntryBase* object);
         //! Read a TiffDataEntryBase from the data buffer
         void readDataEntryBase(TiffDataEntryBase* object);
-        //! Set the \em state class. Assumes ownership of the object passed in.
-        void changeState(TiffRwState::AutoPtr state);
-        //! Reset the state to the original state as set in the constructor.
-        void resetState();
+        /*!
+          @brief Set the \em state of the reader to one suitable for the Makernote.
+
+          Uses the \em state passed in, if any, and remembers it for use during
+          subsequent calls without any argument.
+         */
+        void setMnState(const TiffRwState* state =0);
+        //! Set the state to the original state as set in the constructor.
+        void setOrigState();
         //! Check IFD directory pointer \em start for circular reference
         bool circularReference(const byte* start, IfdId group);
         //! Return the next idx sequence number for \em group
@@ -721,8 +722,9 @@ namespace Exiv2 {
         const uint32_t       size_;       //!< Size of the buffer
         const byte*          pLast_;      //!< Pointer to the last byte
         TiffComponent* const pRoot_;      //!< Root element of the composite
-        TiffRwState*         pState_;     //!< State class
-        TiffRwState*         pOrigState_; //!< State class as set in the c'tor
+        TiffRwState*         pState_;     //!< Pointer to the state in effect (origState_ or mnState_)
+        TiffRwState          origState_;  //!< State class as set in the c'tor
+        TiffRwState          mnState_;    //!< State class as set in the c'tor or by setMnState()
         DirList              dirList_;    //!< List of IFD pointers and their groups
         IdxSeq               idxSeq_;     //!< Sequences for group, used for the entry's idx
         PostList             postList_;   //!< List of components with deferred reading

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list