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

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:40:11 UTC 2017


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

The following commit has been merged in the master branch:
commit 87ac67e5f130f41dd0e60ef1605a82f5e4a1ad42
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Tue Dec 2 13:48:53 2008 +0000

    #580: Fixed return code of modify action (set/add).
---
 src/actions.cpp | 34 +++++++++++++++++++++++++---------
 src/actions.hpp | 12 ++++++------
 2 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/src/actions.cpp b/src/actions.cpp
index de35b4d..973a8ed 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -1243,7 +1243,7 @@ namespace Action {
         assert(image.get() != 0);
         image->readMetadata();
 
-        applyCommands(image.get());
+        int rc = applyCommands(image.get());
 
         // Save both exif and iptc metadata
         image->writeMetadata();
@@ -1251,7 +1251,7 @@ namespace Action {
         if (Params::instance().preserve_) {
             ts.touch(path);
         }
-        return 0;
+        return rc;
     }
     catch(const Exiv2::AnyError& e)
     {
@@ -1261,7 +1261,7 @@ namespace Action {
     }
     } // Modify::run
 
-    void Modify::applyCommands(Exiv2::Image* pImage)
+    int Modify::applyCommands(Exiv2::Image* pImage)
     {
         if (!Params::instance().jpegComment_.empty()) {
             if (Params::instance().verbose_) {
@@ -1277,13 +1277,17 @@ namespace Action {
         ModifyCmds& modifyCmds = Params::instance().modifyCmds_;
         ModifyCmds::const_iterator i = modifyCmds.begin();
         ModifyCmds::const_iterator end = modifyCmds.end();
+        int rc = 0;
+        int ret = 0;
         for (; i != end; ++i) {
             switch (i->cmdId_) {
             case add:
-                addMetadatum(pImage, *i);
+                ret = addMetadatum(pImage, *i);
+                if (rc == 0) rc = ret;
                 break;
             case set:
-                setMetadatum(pImage, *i);
+                ret = setMetadatum(pImage, *i);
+                if (rc == 0) rc = ret;
                 break;
             case del:
                 delMetadatum(pImage, *i);
@@ -1296,9 +1300,10 @@ namespace Action {
                 break;
             }
         }
+        return rc;
     } // Modify::applyCommands
 
-    void Modify::addMetadatum(Exiv2::Image* pImage, const ModifyCmd& modifyCmd)
+    int Modify::addMetadatum(Exiv2::Image* pImage, const ModifyCmd& modifyCmd)
     {
         if (Params::instance().verbose_) {
             std::cout << _("Add") << " " << modifyCmd.key_ << " \""
@@ -1310,7 +1315,8 @@ namespace Action {
         Exiv2::IptcData& iptcData = pImage->iptcData();
         Exiv2::XmpData&  xmpData  = pImage->xmpData();
         Exiv2::Value::AutoPtr value = Exiv2::Value::create(modifyCmd.typeId_);
-        if (0 == value->read(modifyCmd.value_)) {
+        int rc = value->read(modifyCmd.value_);
+        if (0 == rc) {
             if (modifyCmd.metadataId_ == exif) {
                 exifData.add(Exiv2::ExifKey(modifyCmd.key_), value.get());
             }
@@ -1321,11 +1327,19 @@ namespace Action {
                 xmpData.add(Exiv2::XmpKey(modifyCmd.key_), value.get());
             }
         }
+        else {
+            std::cerr << _("Warning") << ": " << modifyCmd.key_ << ": "
+                      << _("Failed to read") << " "
+                      << Exiv2::TypeInfo::typeName(value->typeId())
+                      << " " << _("value")
+                      << " \"" << modifyCmd.value_ << "\"
";
+        }
+        return rc;
     }
 
     // This function looks rather complex because we try to avoid adding an
     // empty metadatum if reading the value fails
-    void Modify::setMetadatum(Exiv2::Image* pImage, const ModifyCmd& modifyCmd)
+    int Modify::setMetadatum(Exiv2::Image* pImage, const ModifyCmd& modifyCmd)
     {
         if (Params::instance().verbose_) {
             std::cout << _("Set") << " " << modifyCmd.key_ << " \""
@@ -1370,7 +1384,8 @@ namespace Action {
                 && modifyCmd.typeId_ != value->typeId())) {
             value = Exiv2::Value::create(modifyCmd.typeId_);
         }
-        if (0 == value->read(modifyCmd.value_)) {
+        int rc = value->read(modifyCmd.value_);
+        if (0 == rc) {
             if (metadatum) {
                 metadatum->setValue(value.get());
             }
@@ -1393,6 +1408,7 @@ namespace Action {
                       << " " << _("value")
                       << " \"" << modifyCmd.value_ << "\"
";
         }
+        return rc;
     }
 
     void Modify::delMetadatum(Exiv2::Image* pImage, const ModifyCmd& modifyCmd)
diff --git a/src/actions.hpp b/src/actions.hpp
index 747a2b4..c64dad3 100644
--- a/src/actions.hpp
+++ b/src/actions.hpp
@@ -324,8 +324,8 @@ namespace Action {
         typedef std::auto_ptr<Modify> AutoPtr;
         AutoPtr clone() const;
         Modify() {}
-        //! Apply modification commands to the \em pImage
-        static void applyCommands(Exiv2::Image* pImage);
+        //! Apply modification commands to the \em pImage, return 0 if successful.
+        static int applyCommands(Exiv2::Image* pImage);
 
     private:
         virtual Modify* clone_() const;
@@ -333,11 +333,11 @@ namespace Action {
         Modify(const Modify& /*src*/) : Task() {}
 
         //! Add a metadatum to \em pImage according to \em modifyCmd
-        static void addMetadatum(Exiv2::Image* pImage,
-                                 const ModifyCmd& modifyCmd);
+        static int addMetadatum(Exiv2::Image* pImage,
+                                const ModifyCmd& modifyCmd);
         //! Set a metadatum in \em pImage according to \em modifyCmd
-        static void setMetadatum(Exiv2::Image* pImage,
-                                 const ModifyCmd& modifyCmd);
+        static int setMetadatum(Exiv2::Image* pImage,
+                                const ModifyCmd& modifyCmd);
         //! Delete a metadatum from \em pImage according to \em modifyCmd
         static void delMetadatum(Exiv2::Image* pImage,
                                  const ModifyCmd& modifyCmd);

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list