diff options
-rw-r--r-- | src/exiv2wrapper.cpp | 12 | ||||
-rw-r--r-- | src/exiv2wrapper.hpp | 3 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/exiv2wrapper.cpp b/src/exiv2wrapper.cpp index 3cdc2d5..646abd9 100644 --- a/src/exiv2wrapper.cpp +++ b/src/exiv2wrapper.cpp @@ -753,7 +753,9 @@ const boost::python::list IptcTag::getRawValues() XmpTag::XmpTag(const std::string& key, Exiv2::Xmpdatum* datum): _key(key) { - if (datum != 0) + _from_datum = (datum != 0); + + if (_from_datum) { _datum = datum; } @@ -784,6 +786,14 @@ XmpTag::XmpTag(const std::string& key, Exiv2::Xmpdatum* datum): _key(key) } } +XmpTag::~XmpTag() +{ + if (!_from_datum) + { + delete _datum; + } +} + void XmpTag::setTextValue(const std::string& value) { _datum->setValue(value); diff --git a/src/exiv2wrapper.hpp b/src/exiv2wrapper.hpp index 13091dd..50470f4 100644 --- a/src/exiv2wrapper.hpp +++ b/src/exiv2wrapper.hpp @@ -111,6 +111,8 @@ public: // Constructor XmpTag(const std::string& key, Exiv2::Xmpdatum* datum=0); + ~XmpTag(); + void setTextValue(const std::string& value); void setArrayValue(const boost::python::list& values); void setLangAltValue(const boost::python::dict& values); @@ -127,6 +129,7 @@ public: private: Exiv2::XmpKey _key; + bool _from_datum; // whether the tag is built from an existing Xmpdatum Exiv2::Xmpdatum* _datum; std::string _exiv2_type; std::string _type; |