[Digikam-devel] [Bug 136855] Editing metadata on a few selected imagefiles and clicking forward or apply crashes digikam.
Gilles Caulier
caulier.gilles at kdemail.net
Wed Nov 8 08:34:56 GMT 2006
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=136855
------- Additional Comments From caulier.gilles kdemail net 2006-11-08 09:34 -------
Andreas,
When i said "good", i want mean "instructive" in fact (:=)))...
About the methods used in Exiv2iface from the MetadataEdit kipi-plugin, it's very simple. look the code from the slots used when we want save the changes in pictures metadata :
In Exif editor dialog, we have :
void EXIFEditDialog::slotApply()
{
if (d->modified && !d->isReadOnly)
{
d->captionPage->applyMetadata(d->exifData);
...
KIPIPlugins::Exiv2Iface exiv2Iface;
exiv2Iface.load((*d->currItem).path());
exiv2Iface.setExif(d->exifData);
exiv2Iface.save((*d->currItem).path());
d->modified = false;
}
}
d->modified and d->isReadOnly are just boolean variables. d->exifData is a bytearray to store metadata.
The IPTC code is similar than Exif :
void IPTCEditDialog::slotApply()
{
if (d->modified && !d->isReadOnly)
{
d->captionPage->applyMetadata(d->iptcData);
...
KIPIPlugins::Exiv2Iface exiv2Iface;
exiv2Iface.load((*d->currItem).path());
exiv2Iface.setExif(d->iptcData);
exiv2Iface.save((*d->currItem).path());
d->modified = false;
}
}
About to load metadata from pictures when user change current selected one to edit in MetadataEdit plugin, we have another slots for Exif :
void EXIFEditDialog::slotItemChanged()
{
KIPIPlugins::Exiv2Iface exiv2Iface;
exiv2Iface.load((*d->currItem).path());
d->exifData = exiv2Iface.getExif();
d->captionPage->readMetadata(d->exifData);
...
d->isReadOnly = KIPIPlugins::Exiv2Iface::isReadOnly((*d->currItem).path());
...
}
... and for IPTC :
void IPTCEditDialog::slotItemChanged()
{
KIPIPlugins::Exiv2Iface exiv2Iface;
exiv2Iface.load((*d->currItem).path());
d->iptcData = exiv2Iface.getIptc();
d->captionPage->readMetadata(d->iptcData);
...
d->isReadOnly = KIPIPlugins::Exiv2Iface::isReadOnly((*d->currItem).path());
...
}
The slotItemChanged() and slotApply() call the dialog page methods to get or set the matadata values on the Exif/IPTC bytearray. this is the readMetadata() and applyMetadata() methods. These one use too another instances of KIPIPlugins::Exiv2Iface class to use others methods relevant of tags manipulations. For example, in Exif Captions editor page, we have :
void EXIFCaption::readMetadata(QByteArray& exifData)
{
...
KIPIPlugins::Exiv2Iface exiv2Iface;
exiv2Iface.setExif(exifData);
QString data;
data = exiv2Iface.getExifTagString("Exif.Image.DocumentName", false);
...
}
void EXIFCaption::applyMetadata(QByteArray& exifData)
{
KIPIPlugins::Exiv2Iface exiv2Iface;
exiv2Iface.setExif(exifData);
if (d->documentNameCheck->isChecked())
exiv2Iface.setExifTagString("Exif.Image.DocumentName", d->documentNameEdit->text());
else
exiv2Iface.removeExifTag("Exif.Image.DocumentName");
...
}
The both class instance are independant and there is no memory conflict here (checked with valgrind). Exiv2Iface do not use static member.
Other important note : this plugin do not use multithreading like in digiKam core. The crash is not relevant of an unthread-safe problem.
You can read all current plugin source code here :
http://websvn.kde.org/trunk/extragear/libs/kipi-plugins/metadataedit
and the Exiv2Iface class here :
http://websvn.kde.org/trunk/extragear/libs/kipi-plugins/common/exiv2iface
Gilles
More information about the Digikam-devel
mailing list