[niepce] Avoid writing empty string to XMP



commit b87db989f38e58296abaf9f8dce57767cbfe73e4
Author: Hubert Figuière <hub figuiere net>
Date:   Thu Jun 20 01:43:57 2013 -0400

    Avoid writing empty string to XMP

 src/engine/db/libmetadata.cpp |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/engine/db/libmetadata.cpp b/src/engine/db/libmetadata.cpp
index fd03425..701be01 100644
--- a/src/engine/db/libmetadata.cpp
+++ b/src/engine/db/libmetadata.cpp
@@ -93,12 +93,17 @@ bool LibMetadata::setMetaData(fwk::PropertyIndex meta,
         }
         else if(value.type() == typeid(std::string)) {
             std::string val = boost::get<std::string>(value);
-            result = xmp_set_property(xmp(), ns, property, val.c_str(), 0);
-            // FIXME we should know in advance it is localized.
-            if(!result && (xmp_get_error() == XMPErr_BadXPath)) {
-                result = xmp_set_localized_text(xmp(), ns, property, 
-                                                "", "x-default", 
-                                                val.c_str(), 0);
+            if (val.empty()) {
+                result = xmp_delete_property(xmp(), ns, property);
+            }
+            else {
+                result = xmp_set_property(xmp(), ns, property, val.c_str(), 0);
+                // FIXME we should know in advance it is localized.
+                if(!result && (xmp_get_error() == XMPErr_BadXPath)) {
+                    result = xmp_set_localized_text(xmp(), ns, property,
+                                                    "", "x-default",
+                                                    val.c_str(), 0);
+                }
             }
         }
         else if(value.type() == typeid(fwk::StringArray)) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]