From 923a3fc14de0b779a45696c5f0aef34c74d84f13 Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Sun, 28 May 2023 18:54:10 +0200 Subject: [PATCH] Fix build with exiv2-0.28 Signed-off-by: Andreas Sturmlechner --- ImageViewer.cpp | 9 +++++++++ MetadataCache.cpp | 8 ++++++++ Phototonic.cpp | 4 ++++ Tags.cpp | 8 ++++++++ ThumbsViewer.cpp | 4 ++++ 5 files changed, 33 insertions(+) diff --git a/ImageViewer.cpp b/ImageViewer.cpp index 357d223..df3ac43 100644 --- a/ImageViewer.cpp +++ b/ImageViewer.cpp @@ -945,7 +945,11 @@ void ImageViewer::keyMoveEvent(int direction) { } void ImageViewer::saveImage() { +#if EXIV2_TEST_VERSION(0,28,0) + Exiv2::Image::UniquePtr image; +#else Exiv2::Image::AutoPtr image; +#endif bool exifError = false; if (newImage) { @@ -985,8 +989,13 @@ void ImageViewer::saveImage() { } void ImageViewer::saveImageAs() { +#if EXIV2_TEST_VERSION(0,28,0) + Exiv2::Image::UniquePtr exifImage; + Exiv2::Image::UniquePtr newExifImage; +#else Exiv2::Image::AutoPtr exifImage; Exiv2::Image::AutoPtr newExifImage; +#endif bool exifError = false; setCursorHiding(false); diff --git a/MetadataCache.cpp b/MetadataCache.cpp index 524ae74..5ddd4c8 100644 --- a/MetadataCache.cpp +++ b/MetadataCache.cpp @@ -64,7 +64,11 @@ void MetadataCache::clear() { } bool MetadataCache::loadImageMetadata(const QString &imageFullPath) { +#if EXIV2_TEST_VERSION(0,28,0) + Exiv2::Image::UniquePtr exifImage; +#else Exiv2::Image::AutoPtr exifImage; +#endif QSet tags; long orientation = 0; @@ -78,7 +82,11 @@ bool MetadataCache::loadImageMetadata(const QString &imageFullPath) { try { Exiv2::ExifData &exifData = exifImage->exifData(); if (!exifData.empty()) { +#if EXIV2_TEST_VERSION(0,28,0) + orientation = exifData["Exif.Image.Orientation"].value().toUint32(); +#else orientation = exifData["Exif.Image.Orientation"].value().toLong(); +#endif } } catch (Exiv2::Error &error) { qWarning() << "Failed to read Exif metadata"; diff --git a/Phototonic.cpp b/Phototonic.cpp index 6cc95b3..bd5497d 100644 --- a/Phototonic.cpp +++ b/Phototonic.cpp @@ -3151,7 +3151,11 @@ void Phototonic::removeMetadata() { if (ret == MessageBox::Yes) { for (int file = 0; file < fileList.size(); ++file) { +#if EXIV2_TEST_VERSION(0,28,0) + Exiv2::Image::UniquePtr image; +#else Exiv2::Image::AutoPtr image; +#endif try { image = Exiv2::ImageFactory::open(fileList[file].toStdString()); image->clearMetadata(); diff --git a/Tags.cpp b/Tags.cpp index 84eea16..a62da9d 100644 --- a/Tags.cpp +++ b/Tags.cpp @@ -136,7 +136,11 @@ void ImageTags::addTag(QString tagName, bool tagChecked) { bool ImageTags::writeTagsToImage(QString &imageFileName, QSet &newTags) { QSet imageTags; +#if EXIV2_TEST_VERSION(0,28,0) + Exiv2::Image::UniquePtr exifImage; +#else Exiv2::Image::AutoPtr exifImage; +#endif try { exifImage = Exiv2::ImageFactory::open(imageFileName.toStdString()); @@ -160,7 +164,11 @@ bool ImageTags::writeTagsToImage(QString &imageFileName, QSet &newTags) QSetIterator newTagsIt(newTags); while (newTagsIt.hasNext()) { QString tag = newTagsIt.next(); +#if EXIV2_TEST_VERSION(0,28,0) + Exiv2::Value::UniquePtr value = Exiv2::Value::create(Exiv2::string); +#else Exiv2::Value::AutoPtr value = Exiv2::Value::create(Exiv2::string); +#endif value->read(tag.toStdString()); Exiv2::IptcKey key("Iptc.Application2.Keywords"); newIptcData.add(key, value.get()); diff --git a/ThumbsViewer.cpp b/ThumbsViewer.cpp index 77a6189..4a11475 100644 --- a/ThumbsViewer.cpp +++ b/ThumbsViewer.cpp @@ -210,7 +210,11 @@ void ThumbsViewer::updateImageInfoViewer(QString imageFullPath) { infoView->addEntry(key, val); } +#if EXIV2_TEST_VERSION(0,28,0) + Exiv2::Image::UniquePtr exifImage; +#else Exiv2::Image::AutoPtr exifImage; +#endif try { exifImage = Exiv2::ImageFactory::open(imageFullPath.toStdString()); exifImage->readMetadata(); -- 2.40.1