aboutsummaryrefslogtreecommitdiffstats
path: root/src/exiv2wrapper.cpp
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2010-08-24 19:47:36 +0200
committerOlivier Tilloy <olivier@tilloy.net>2010-08-24 19:47:36 +0200
commit986c01a1dffaf1e5f1e38620fc0e0556b74d2da0 (patch)
tree08ba59fab94d3878a0c620905ebb84e5c2dc9777 /src/exiv2wrapper.cpp
parent2a010332df401e2f09dcd51f73ff0b3aa89bdf64 (diff)
downloadpyexiv2-986c01a1dffaf1e5f1e38620fc0e0556b74d2da0.tar.gz
Sanity check when setting the parent image of a tag:
if it’s already the same parent, don’t do anything.
Diffstat (limited to 'src/exiv2wrapper.cpp')
-rw-r--r--src/exiv2wrapper.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/exiv2wrapper.cpp b/src/exiv2wrapper.cpp
index e29569d..121062e 100644
--- a/src/exiv2wrapper.cpp
+++ b/src/exiv2wrapper.cpp
@@ -482,7 +482,15 @@ void ExifTag::setRawValue(const std::string& value)
void ExifTag::setParentImage(Image& image)
{
- _data = image.getExifData();
+ Exiv2::ExifData* data = image.getExifData();
+ if (data == _data)
+ {
+ // The parent image is already the one passed as a parameter.
+ // This happens when replacing a tag by itself. In this case, don’t do
+ // anything (see https://bugs.launchpad.net/pyexiv2/+bug/622739).
+ return;
+ }
+ _data = data;
std::string value = _datum->toString();
delete _datum;
_datum = &(*_data)[_key.key()];
@@ -646,10 +654,18 @@ void IptcTag::setRawValues(const boost::python::list& values)
void IptcTag::setParentImage(Image& image)
{
+ Exiv2::IptcData* data = image.getIptcData();
+ if (data == _data)
+ {
+ // The parent image is already the one passed as a parameter.
+ // This happens when replacing a tag by itself. In this case, don’t do
+ // anything (see https://bugs.launchpad.net/pyexiv2/+bug/622739).
+ return;
+ }
const boost::python::list values = getRawValues();
delete _data;
_from_data = true;
- _data = image.getIptcData();
+ _data = data;
setRawValues(values);
}
@@ -791,6 +807,14 @@ void XmpTag::setLangAltValue(const boost::python::dict& values)
void XmpTag::setParentImage(Image& image)
{
+ Exiv2::Xmpdatum* datum = &(*image.getXmpData())[_key.key()];
+ if (datum == _datum)
+ {
+ // The parent image is already the one passed as a parameter.
+ // This happens when replacing a tag by itself. In this case, don’t do
+ // anything (see https://bugs.launchpad.net/pyexiv2/+bug/622739).
+ return;
+ }
switch (Exiv2::XmpProperties::propertyType(_key))
{
case Exiv2::xmpText: