~osomon/pyexiv2/pyexiv2-0.3

« back to all changes in this revision

Viewing changes to src/exiv2wrapper.cpp

  • Committer: Olivier Tilloy
  • Date: 2010-08-24 17:47:36 UTC
  • mto: This revision was merged to the branch mainline in revision 321.
  • Revision ID: olivier@tilloy.net-20100824174736-8qsmswffeigkm10x
Sanity check when setting the parent image of a tag:
if it’s already the same parent, don’t do anything.

Show diffs side-by-side

added added

removed removed

Lines of Context:
482
482
 
483
483
void ExifTag::setParentImage(Image& image)
484
484
{
485
 
    _data = image.getExifData();
 
485
    Exiv2::ExifData* data = image.getExifData();
 
486
    if (data == _data)
 
487
    {
 
488
        // The parent image is already the one passed as a parameter.
 
489
        // This happens when replacing a tag by itself. In this case, don’t do
 
490
        // anything (see https://bugs.launchpad.net/pyexiv2/+bug/622739).
 
491
        return;
 
492
    }
 
493
    _data = data;
486
494
    std::string value = _datum->toString();
487
495
    delete _datum;
488
496
    _datum = &(*_data)[_key.key()];
646
654
 
647
655
void IptcTag::setParentImage(Image& image)
648
656
{
 
657
    Exiv2::IptcData* data = image.getIptcData();
 
658
    if (data == _data)
 
659
    {
 
660
        // The parent image is already the one passed as a parameter.
 
661
        // This happens when replacing a tag by itself. In this case, don’t do
 
662
        // anything (see https://bugs.launchpad.net/pyexiv2/+bug/622739).
 
663
        return;
 
664
    }
649
665
    const boost::python::list values = getRawValues();
650
666
    delete _data;
651
667
    _from_data = true;
652
 
    _data = image.getIptcData();
 
668
    _data = data;
653
669
    setRawValues(values);
654
670
}
655
671
 
791
807
 
792
808
void XmpTag::setParentImage(Image& image)
793
809
{
 
810
    Exiv2::Xmpdatum* datum = &(*image.getXmpData())[_key.key()];
 
811
    if (datum == _datum)
 
812
    {
 
813
        // The parent image is already the one passed as a parameter.
 
814
        // This happens when replacing a tag by itself. In this case, don’t do
 
815
        // anything (see https://bugs.launchpad.net/pyexiv2/+bug/622739).
 
816
        return;
 
817
    }
794
818
    switch (Exiv2::XmpProperties::propertyType(_key))
795
819
    {
796
820
        case Exiv2::xmpText: