Patch-Source: https://github.com/nomacs/nomacs/issues/951
--
--- a/ImageLounge/src/DkCore/DkMetaData.cpp	2023-06-09 10:18:22.687055840 +0300
+++ b/ImageLounge/src/DkCore/DkMetaData.cpp	2023-06-09 09:08:41.039291372 +0300
@@ -69,7 +69,7 @@
         // ImageFactory::create(type) may crash even if old Image object has that type
         try {
             // Load new Exiv2::Image object
-            int i_type = mExifImg->imageType();
+            Exiv2::ImageType i_type = mExifImg->imageType();
             metaDataN->mExifImg = Exiv2::ImageFactory::create(i_type);
             // Copy exif data from old object into new object
             Exiv2::ExifData data = mExifImg->exifData();
@@ -114,8 +114,7 @@
             std::string strFilePath = (fileInfo.isSymLink()) ? fileInfo.symLinkTarget().toStdString() : filePath.toStdString();
             mExifImg = Exiv2::ImageFactory::open(strFilePath);
         } else {
-            Exiv2::BasicIo::AutoPtr exifBuffer(new Exiv2::MemIo((const byte *)ba->constData(), ba->size()));
-            mExifImg = Exiv2::ImageFactory::open(exifBuffer);
+            mExifImg = Exiv2::ImageFactory::open((const byte *)ba->constData(), ba->size());
         }
     } catch (...) {
         // TODO: check crashes here
@@ -217,13 +216,11 @@
     Exiv2::XmpData &xmpData = mExifImg->xmpData();
     Exiv2::IptcData &iptcData = mExifImg->iptcData();
 
-    Exiv2::Image::AutoPtr exifImgN;
-    Exiv2::MemIo::AutoPtr exifMem;
+    Exiv2::Image::UniquePtr exifImgN;
 
     try {
         // Load new exif object (based on byte array of raw image file, see overload)
-        exifMem = Exiv2::MemIo::AutoPtr(new Exiv2::MemIo((byte *)ba->data(), ba->size()));
-        exifImgN = Exiv2::ImageFactory::open(exifMem);
+        exifImgN = Exiv2::ImageFactory::open((byte *)ba->data(), ba->size());
     } catch (...) {
         qDebug() << "could not open image for exif data";
         return false;
@@ -246,8 +243,8 @@
     // Copy image + new exif and return temporary object as byte array
     // The calling function should then write it back to the file
     Exiv2::DataBuf exifBuf = exifImgN->io().read((long)exifImgN->io().size());
-    if (exifBuf.pData_) {
-        QSharedPointer<QByteArray> tmp = QSharedPointer<QByteArray>(new QByteArray((const char *)exifBuf.pData_, exifBuf.size_));
+    if (!exifBuf.empty()) {
+        QSharedPointer<QByteArray> tmp = QSharedPointer<QByteArray>(new QByteArray((const char *)exifBuf.c_data(), exifBuf.size()));
 
         if (tmp->size() > qRound(ba->size() * 0.5f))
             ba = tmp;
@@ -257,7 +254,7 @@
         return false;
 
     // Replace old exif object with new one and clear "dirty" flag
-    mExifImg = exifImgN;
+    mExifImg.swap(exifImgN);
     mExifState = loaded;
 
     return true;
@@ -304,7 +301,7 @@
             Exiv2::ExifData::iterator pos = exifData.findKey(key);
 
             if (pos != exifData.end() && pos->count() != 0) {
-                Exiv2::Value::AutoPtr v = pos->getValue();
+                Exiv2::Value::UniquePtr v = pos->getValue();
                 orientation = (int)pos->toFloat();
 
                 switch (orientation) {
@@ -384,7 +381,7 @@
         Exiv2::ExifData::iterator pos = exifData.findKey(key);
 
         if (pos != exifData.end() && pos->count() != 0) {
-            Exiv2::Value::AutoPtr v = pos->getValue();
+            Exiv2::Value::UniquePtr v = pos->getValue();
             exifRating = v->toFloat();
         }
     }
@@ -396,7 +393,7 @@
 
         // xmp Rating tag
         if (pos != xmpData.end() && pos->count() != 0) {
-            Exiv2::Value::AutoPtr v = pos->getValue();
+            Exiv2::Value::UniquePtr v = pos->getValue();
             xmpRating = v->toFloat();
         }
 
@@ -405,7 +402,7 @@
             key = Exiv2::XmpKey("Xmp.MicrosoftPhoto.Rating");
             pos = xmpData.findKey(key);
             if (pos != xmpData.end() && pos->count() != 0) {
-                Exiv2::Value::AutoPtr v = pos->getValue();
+                Exiv2::Value::UniquePtr v = pos->getValue();
                 xmpRating = v->toFloat();
             }
         }
@@ -505,7 +502,7 @@
         }
 
         if (pos != xmpData.end() && pos->count() != 0) {
-            Exiv2::Value::AutoPtr v = pos->getValue();
+            Exiv2::Value::UniquePtr v = pos->getValue();
             info = exiv2ToQString(pos->toString());
         }
     }
@@ -573,7 +570,7 @@
         }
 
         if (pos != iptcData.end() && pos->count() != 0) {
-            Exiv2::Value::AutoPtr v = pos->getValue();
+            Exiv2::Value::UniquePtr v = pos->getValue();
             info = exiv2ToQString(pos->toString());
         }
     }
@@ -715,7 +712,7 @@
         Exiv2::ExifThumb thumb(exifData);
         Exiv2::DataBuf buffer = thumb.copy();
 
-        QByteArray ba = QByteArray((char *)buffer.pData_, buffer.size_);
+        QByteArray ba = QByteArray((char *)buffer.c_data(), buffer.size());
         qThumb.loadFromData(ba);
     } catch (...) {
         qDebug() << "Sorry, I could not load the thumb from the exif data...";
@@ -994,8 +991,7 @@
 
         try {
             // whipe all exif data of the thumbnail
-            Exiv2::MemIo::AutoPtr exifBufferThumb(new Exiv2::MemIo((const byte *)ba.constData(), ba.size()));
-            Exiv2::Image::AutoPtr exifImgThumb = Exiv2::ImageFactory::open(exifBufferThumb);
+            Exiv2::Image::UniquePtr exifImgThumb = Exiv2::ImageFactory::open((const byte *)ba.constData(), ba.size());
 
             if (exifImgThumb.get() != 0 && exifImgThumb->good())
                 exifImgThumb->clearExifData();
@@ -1106,12 +1102,12 @@
         pos = exifData.findKey(key);
     }
 
-    Exiv2::Value::AutoPtr v = pos->getValue();
+    Exiv2::Value::UniquePtr v = pos->getValue();
     Exiv2::UShortValue *prv = dynamic_cast<Exiv2::UShortValue *>(v.release());
     if (!prv)
         return;
 
-    Exiv2::UShortValue::AutoPtr rv = Exiv2::UShortValue::AutoPtr(prv);
+    Exiv2::UShortValue::UniquePtr rv = Exiv2::UShortValue::UniquePtr(prv);
     if (rv->value_.empty())
         return;
 
@@ -1202,7 +1198,7 @@
         exifData["Exif.Image.Rating"] = uint16_t(r);
         exifData["Exif.Image.RatingPercent"] = uint16_t(r);
 
-        Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::xmpText);
+        Exiv2::Value::UniquePtr v = Exiv2::Value::create(Exiv2::xmpText);
         v->read(sRating);
         xmpData.add(Exiv2::XmpKey("Xmp.xmp.Rating"), v.get());
         v->read(sRatingPercent);
@@ -1448,9 +1444,9 @@
     return DkRotatingRect(rr);
 }
 
-Exiv2::Image::AutoPtr DkMetaDataT::loadSidecar(const QString &filePath) const
+Exiv2::Image::UniquePtr DkMetaDataT::loadSidecar(const QString &filePath) const
 {
-    Exiv2::Image::AutoPtr xmpImg;
+    Exiv2::Image::UniquePtr xmpImg;
 
     // TODO: check if the file type supports xmp
 
@@ -1500,7 +1496,7 @@
         if (!pos->setValue(xmpValue.toStdString()))
             setXMPValueSuccessful = true;
     } else {
-        Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::xmpText);
+        Exiv2::Value::UniquePtr v = Exiv2::Value::create(Exiv2::xmpText);
         if (!v->read(xmpValue.toStdString())) {
             if (!xmpData.add(Exiv2::XmpKey(key), v.get()))
                 setXMPValueSuccessful = true;
diff -ruN a/ImageLounge/src/DkCore/DkMetaData.h b/ImageLounge/src/DkCore/DkMetaData.h
--- a/ImageLounge/src/DkCore/DkMetaData.h	2023-06-09 10:18:22.687055840 +0300
+++ b/ImageLounge/src/DkCore/DkMetaData.h	2023-06-09 08:52:41.367052948 +0300
@@ -155,7 +155,7 @@
     bool setXMPValue(Exiv2::XmpData &xmpData, QString xmpKey, QString xmpValue);
 
 protected:
-    Exiv2::Image::AutoPtr loadSidecar(const QString &filePath) const;
+    Exiv2::Image::UniquePtr loadSidecar(const QString &filePath) const;
 
     enum {
         not_loaded,
@@ -164,7 +164,7 @@
         dirty,
     };
 
-    Exiv2::Image::AutoPtr mExifImg; // TODO std::unique_ptr<Exiv2::Image> (and all other *::AutoPtr)
+    Exiv2::Image::UniquePtr mExifImg; // TODO std::unique_ptr<Exiv2::Image> (and all other *::AutoPtr)
     QString mFilePath;
     QStringList mQtKeys;
     QStringList mQtValues;
