Fix: do not clear old XMP packet in case of an error encoding the new XMP data.

v0.27.3
Andreas Huggel 18 years ago
parent 595665be33
commit 6d0cfca1a5

@ -526,11 +526,15 @@ namespace Exiv2 {
} }
} }
if (writeXmpFromPacket() == false) { if (writeXmpFromPacket() == false) {
if (XmpParser::encode(xmpPacket_, xmpData_)) { std::string tmpXmpPacket;
if (XmpParser::encode(tmpXmpPacket, xmpData_)) {
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
std::cerr << "Warning: Failed to encode XMP metadata.\n"; std::cerr << "Error: Failed to encode XMP metadata.\n";
#endif #endif
} }
else {
xmpPacket_ = tmpXmpPacket;
}
} }
if (xmpPacket_.size() > 0) { if (xmpPacket_.size() > 0) {
// Write APP1 marker, size of APP1 field, XMP id and XMP packet // Write APP1 marker, size of APP1 field, XMP id and XMP packet

Loading…
Cancel
Save