git: 164a774986db - main - graphics/rawstudio: make compatible with exiv2 0.28

From: Matthias Andree <mandree_at_FreeBSD.org>
Date: Sun, 09 Jul 2023 22:09:44 UTC
The branch main has been updated by mandree:

URL: https://cgit.FreeBSD.org/ports/commit/?id=164a774986db9c3161e903ddd059f6e54c7b5981

commit 164a774986db9c3161e903ddd059f6e54c7b5981
Author:     Matthias Andree <mandree@FreeBSD.org>
AuthorDate: 2023-07-02 21:45:05 +0000
Commit:     Matthias Andree <mandree@FreeBSD.org>
CommitDate: 2023-07-09 22:08:11 +0000

    graphics/rawstudio: make compatible with exiv2 0.28
    
    PR:             272311
---
 graphics/rawstudio/Makefile                        |  2 +-
 .../rawstudio/files/patch-librawstudio_rs-exif.cc  | 65 +++++++++++++++++++
 .../patch-plugins_load-gdk_exiv2-colorspace.cpp    | 39 ++++++++++++
 .../patch-plugins_meta-exiv2_exiv2-metadata.cpp    | 72 ++++++++++++++++++++++
 4 files changed, 177 insertions(+), 1 deletion(-)

diff --git a/graphics/rawstudio/Makefile b/graphics/rawstudio/Makefile
index 012718ecd940..be8cc343842e 100644
--- a/graphics/rawstudio/Makefile
+++ b/graphics/rawstudio/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	rawstudio
 PORTVERSION=	2.0
-PORTREVISION=	23
+PORTREVISION=	24
 CATEGORIES=	graphics
 MASTER_SITES=	http://rawstudio.org/files/release/
 
diff --git a/graphics/rawstudio/files/patch-librawstudio_rs-exif.cc b/graphics/rawstudio/files/patch-librawstudio_rs-exif.cc
index b6ba4a48bf13..2431223e2666 100644
--- a/graphics/rawstudio/files/patch-librawstudio_rs-exif.cc
+++ b/graphics/rawstudio/files/patch-librawstudio_rs-exif.cc
@@ -9,3 +9,68 @@
  #include "rs-exif.h"
  #include <assert.h>
  #include "rs-library.h"
+@@ -128,7 +130,7 @@ rs_exif_load_from_file(const gchar *filename)
+ 	RS_EXIF_DATA *exif_data;
+ 	try
+ 	{
+-		Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(filename);
++		Exiv2::Image::UniquePtr image { Exiv2::ImageFactory::open(filename) };
+ 		assert(image.get() != 0);
+ 		image->readMetadata();
+ 
+@@ -136,7 +138,7 @@ rs_exif_load_from_file(const gchar *filename)
+ 
+ 		exif_data_init(exif_data);
+ 	}
+-	catch (Exiv2::AnyError& e)
++	catch (Exiv2::Error& e)
+ 	{
+ 		g_warning("Could not load EXIF data from file %s", filename);
+ 		return NULL;
+@@ -151,8 +153,8 @@ rs_exif_load_from_rawfile(RAWFILE *rawfile)
+ 	RS_EXIF_DATA *rs_exif_data;
+ 	try
+ 	{
+-		Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(
+-			(const Exiv2::byte*) raw_get_map(rawfile), raw_get_filesize(rawfile));
++		Exiv2::Image::UniquePtr image { Exiv2::ImageFactory::open(
++			(const Exiv2::byte*) raw_get_map(rawfile), raw_get_filesize(rawfile)) };
+ 
+ 		assert(image.get() != 0);
+ 		image->readMetadata();
+@@ -161,7 +163,7 @@ rs_exif_load_from_rawfile(RAWFILE *rawfile)
+ 
+ 		exif_data_init(rs_exif_data);
+ 	}
+-	catch (Exiv2::AnyError& e)
++	catch (Exiv2::Error& e)
+ 	{
+ 		g_warning("Could not load EXIF data");
+ 		return NULL;
+@@ -179,7 +181,7 @@ rs_exif_add_to_file(RS_EXIF_DATA *d, Exiv2::IptcData &
+ 	try
+ 	{
+ 		Exiv2::ExifData *data = (Exiv2::ExifData *) d;
+-		Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(filename);
++		Exiv2::Image::UniquePtr image { Exiv2::ImageFactory::open(filename) };
+ 
+ 		/* Copy EXIF to XMP */
+ #if EXIV2_TEST_VERSION(0,17,0)
+@@ -194,7 +196,7 @@ rs_exif_add_to_file(RS_EXIF_DATA *d, Exiv2::IptcData &
+ 		image->setIptcData(iptc_data);
+ 		image->writeMetadata();
+ 	}
+-	catch (Exiv2::AnyError& e)
++	catch (Exiv2::Error& e)
+ 	{
+ 		g_warning("Couldn't add EXIF data to %s", filename);
+ 	}
+@@ -263,7 +265,7 @@ rs_add_tags_exif(RS_EXIF_DATA *d, const gchar *input_f
+ 
+ 	glong items_written;
+ 	gunichar2 *w = g_utf8_to_utf16(xpkeyw->str, -1, NULL, &items_written, NULL);
+-	Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::unsignedByte);
++	Exiv2::Value::UniquePtr v { Exiv2::Value::create(Exiv2::unsignedByte) };
+ 	v->read((const Exiv2::byte*)w, items_written * sizeof(gunichar2), Exiv2::invalidByteOrder);
+ 	Exiv2::ExifKey key = Exiv2::ExifKey("Exif.Image.XPKeywords");
+ 	data->add(key, v.get());
diff --git a/graphics/rawstudio/files/patch-plugins_load-gdk_exiv2-colorspace.cpp b/graphics/rawstudio/files/patch-plugins_load-gdk_exiv2-colorspace.cpp
index 66b5ee793016..bbb02c33175e 100644
--- a/graphics/rawstudio/files/patch-plugins_load-gdk_exiv2-colorspace.cpp
+++ b/graphics/rawstudio/files/patch-plugins_load-gdk_exiv2-colorspace.cpp
@@ -23,3 +23,42 @@
  						if (retval != 0)
  						{
  							RSIccProfile *icc = rs_icc_profile_new_from_memory((gchar*)icc_profile, icc_profile_size, TRUE);
+@@ -151,7 +153,7 @@ jpeg_fail:
+ #endif
+ 
+ 	try {
+-		Image::AutoPtr img = ImageFactory::open(filename);
++		Image::UniquePtr img { ImageFactory::open(filename) };
+ 		img->readMetadata();
+ 		ExifData &exifData = img->exifData();
+ 		*linear_guess = FALSE;
+@@ -169,13 +171,13 @@ jpeg_fail:
+ 			ExifData::const_iterator i;
+ 			i = exifData.findKey(ExifKey("Exif.Image.BitsPerSample"));
+ 			if (i != exifData.end())
+-				if (i->toLong() == 16)
++				if (i->toInt64() == 16)
+ 					*linear_guess = TRUE;
+ 			
+ 			i = exifData.findKey(ExifKey("Exif.Photo.ColorSpace"));
+ 			if (i != exifData.end())
+ 			{
+-				if (i->toLong() == 1)
++				if (i->toInt64() == 1)
+ 					return rs_color_space_new_singleton("RSSrgb");
+ 			}
+ 
+@@ -184,10 +186,10 @@ jpeg_fail:
+ 			if (i != exifData.end())
+ 			{
+ 				DataBuf buf(i->size());
+-				i->copy(buf.pData_, Exiv2::invalidByteOrder);
+-				if (buf.pData_ && buf.size_)
++				i->copy(buf.data(), Exiv2::invalidByteOrder);
++				if (buf.c_data() && buf.size())
+ 				{
+-					RSIccProfile *icc = rs_icc_profile_new_from_memory((gchar*)buf.pData_, buf.size_, TRUE);
++					RSIccProfile *icc = rs_icc_profile_new_from_memory((gchar*)buf.c_data(), buf.size(), TRUE);
+ 					return rs_color_space_icc_new_from_icc(icc);
+ 				}
+ 			}
diff --git a/graphics/rawstudio/files/patch-plugins_meta-exiv2_exiv2-metadata.cpp b/graphics/rawstudio/files/patch-plugins_meta-exiv2_exiv2-metadata.cpp
index c78ebecd9bf2..fb735ba22727 100644
--- a/graphics/rawstudio/files/patch-plugins_meta-exiv2_exiv2-metadata.cpp
+++ b/graphics/rawstudio/files/patch-plugins_meta-exiv2_exiv2-metadata.cpp
@@ -9,3 +9,75 @@
  #include <assert.h>
  #include "exiv2-metadata.h"
  #include <math.h>
+@@ -94,7 +96,7 @@ gboolean
+ exiv2_load_meta_interface(const gchar *service, RAWFILE *rawfile, guint offset, RSMetadata *meta)
+ {
+ 	try {
+-		Image::AutoPtr img = ImageFactory::open((byte*)raw_get_map(rawfile), raw_get_filesize(rawfile));
++		Image::UniquePtr img { ImageFactory::open((byte*)raw_get_map(rawfile), raw_get_filesize(rawfile)) };
+ 		img->readMetadata();
+ 		ExifData &exifData = img->exifData();
+ 
+@@ -121,7 +123,7 @@ exiv2_load_meta_interface(const gchar *service, RAWFIL
+ 			i = orientation(exifData);
+ 			if (i != exifData.end())
+ 			{
+-				switch (i->getValue()->toLong())
++				switch (i->getValue()->toInt64())
+ 				{
+ 						case 6: meta->orientation = 90;
+ 							break;
+@@ -173,7 +175,7 @@ exiv2_load_meta_interface(const gchar *service, RAWFIL
+ #if EXIV2_TEST_VERSION(0,19,0)
+ 			i = isoSpeed(exifData);
+ 			if (i != exifData.end())
+-				meta->iso = i->toLong();
++				meta->iso = i->toInt64();
+ 
+ 			/* Text based Lens Identifier */
+ 			i = lensName(exifData);
+@@ -181,7 +183,7 @@ exiv2_load_meta_interface(const gchar *service, RAWFIL
+ 			{
+ 				TypeId type = i->typeId();
+ 				if (type == unsignedShort || type == unsignedLong || type == signedShort || type == signedLong || type == unsignedByte || type == signedByte)
+-					meta->lens_id = i->toLong();
++					meta->lens_id = i->toInt64();
+ 				else if (type == asciiString || type == string)
+ 					meta->fixed_lens_identifier = g_strdup(i->toString().c_str());
+ 			}
+@@ -223,7 +225,7 @@ exiv2_load_meta_interface(const gchar *service, RAWFIL
+ 			if (i == exifData.end())
+ 				i = exifData.findKey(ExifKey("Exif.NikonLd3.MinFocalLength"));
+ 			if (i != exifData.end())
+-				meta->lens_min_focal = 5.0 * pow(2.0, i->toLong()/24.0);
++				meta->lens_min_focal = 5.0 * pow(2.0, i->toInt64()/24.0);
+ 
+ 			i = exifData.findKey(ExifKey("Exif.NikonLd1.MaxFocalLength"));
+ 			if (i == exifData.end())
+@@ -231,7 +233,7 @@ exiv2_load_meta_interface(const gchar *service, RAWFIL
+ 			if (i == exifData.end())
+ 				i = exifData.findKey(ExifKey("Exif.NikonLd3.MaxFocalLength"));
+ 			if (i != exifData.end())
+-				meta->lens_max_focal = 5.0 * pow(2.0, i->toLong()/24.0);
++				meta->lens_max_focal = 5.0 * pow(2.0, i->toInt64()/24.0);
+ 
+ 			i = exifData.findKey(ExifKey("Exif.NikonLd1.MaxApertureAtMinFocal"));
+ 			if (i == exifData.end())
+@@ -239,7 +241,7 @@ exiv2_load_meta_interface(const gchar *service, RAWFIL
+ 			if (i == exifData.end())
+ 				i = exifData.findKey(ExifKey("Exif.NikonLd3.MaxApertureAtMinFocal"));
+ 			if (i != exifData.end())
+-				meta->lens_min_aperture = i->toLong()/12.0;
++				meta->lens_min_aperture = i->toInt64()/12.0;
+ 			
+ 			i = exifData.findKey(ExifKey("Exif.NikonLd1.MaxApertureAtMaxFocal"));
+ 			if (i == exifData.end())
+@@ -247,7 +249,7 @@ exiv2_load_meta_interface(const gchar *service, RAWFIL
+ 			if (i == exifData.end())
+ 				i = exifData.findKey(ExifKey("Exif.NikonLd3.MaxApertureAtMaxFocal"));
+ 			if (i != exifData.end())
+-				meta->lens_max_aperture = i->toLong()/12.0;
++				meta->lens_max_aperture = i->toInt64()/12.0;
+ 				
+ 			/* Fuji */
+ 			i = exifData.findKey(ExifKey("Exif.Fujifilm.MinFocalLength"));