SHA256
1
0
forked from pool/krita
Christophe Marin 2023-07-04 07:14:46 +00:00 committed by Git OBS Bridge
parent f180d2405b
commit 8f1c3eda5d
3 changed files with 641 additions and 0 deletions

View File

@ -0,0 +1,589 @@
From 4a9a916012b949c9dda6833e4e44e932d38993d4 Mon Sep 17 00:00:00 2001
From: Antonio Rojas <arojas@archlinux.org>
Date: Sun, 4 Jun 2023 18:04:59 +0200
Subject: [PATCH] Fix build with exiv2 0.28
---
plugins/impex/jpeg/kis_jpeg_converter.cc | 8 ++
plugins/impex/tiff/kis_tiff_export.cc | 9 +++
plugins/impex/tiff/kis_tiff_import.cc | 9 +++
plugins/metadata/common/KisExiv2IODevice.cpp | 36 +++++++++
plugins/metadata/common/KisExiv2IODevice.h | 23 ++++++
plugins/metadata/common/kis_exiv2_common.h | 26 ++++++-
plugins/metadata/exif/kis_exif_io.cpp | 79 +++++++++++++++++++-
plugins/metadata/iptc/kis_iptc_io.cpp | 12 +++
plugins/metadata/xmp/kis_xmp_io.cpp | 9 ++-
9 files changed, 202 insertions(+), 9 deletions(-)
diff --git a/plugins/impex/jpeg/kis_jpeg_converter.cc b/plugins/impex/jpeg/kis_jpeg_converter.cc
index 3364ae6..476151e 100644
--- a/plugins/impex/jpeg/kis_jpeg_converter.cc
+++ b/plugins/impex/jpeg/kis_jpeg_converter.cc
@@ -20,6 +20,10 @@ extern "C" {
}
#include <exiv2/jpgimage.hpp>
+#include <exiv2/version.hpp>
+#if EXIV2_TEST_VERSION(0,28,0)
+#include <exiv2/photoshop.hpp>
+#endif
#include <QFile>
#include <QBuffer>
@@ -376,7 +380,11 @@ KisImportExportErrorCode KisJPEGConverter::decode(QIODevice *io)
uint32_t sizeHdr = 0;
// Find actual Iptc data within the APP13 segment
if (!Exiv2::Photoshop::locateIptcIrb((Exiv2::byte*)(marker->data + 14),
+#if EXIV2_TEST_VERSION(0,28,0)
+ marker->data_length - 14, &record, sizeHdr, sizeIptc)) {
+#else
marker->data_length - 14, &record, &sizeHdr, &sizeIptc)) {
+#endif
if (sizeIptc) {
// Decode the IPTC data
QByteArray byteArray((const char*)(record + sizeHdr), sizeIptc);
diff --git a/plugins/impex/tiff/kis_tiff_export.cc b/plugins/impex/tiff/kis_tiff_export.cc
index 8c8f71d..69cbda6 100644
--- a/plugins/impex/tiff/kis_tiff_export.cc
+++ b/plugins/impex/tiff/kis_tiff_export.cc
@@ -206,7 +206,11 @@ KisImportExportErrorCode KisTIFFExport::convert(KisDocument *document, QIODevice
try {
KisExiv2IODevice::ptr_type basicIoDevice(new KisExiv2IODevice(filename()));
+#if EXIV2_TEST_VERSION(0,28,0)
+ const std::unique_ptr<Exiv2::Image> img = Exiv2::ImageFactory::open(std::move(basicIoDevice));
+#else
const std::unique_ptr<Exiv2::Image> img(Exiv2::ImageFactory::open(basicIoDevice).release());
+#endif
img->readMetadata();
@@ -241,9 +245,14 @@ KisImportExportErrorCode KisTIFFExport::convert(KisDocument *document, QIODevice
}
// Write metadata
img->writeMetadata();
+#if EXIV2_TEST_VERSION(0,28,0)
+ } catch (Exiv2::Error &e) {
+ errFile << "Failed injecting TIFF metadata:" << Exiv2::Error(e.code()).what();
+#else
} catch (Exiv2::AnyError &e) {
errFile << "Failed injecting TIFF metadata:" << e.code()
<< e.what();
+#endif
}
}
return ImportExportCodes::OK;
diff --git a/plugins/impex/tiff/kis_tiff_import.cc b/plugins/impex/tiff/kis_tiff_import.cc
index 3845cc5..19b37d7 100644
--- a/plugins/impex/tiff/kis_tiff_import.cc
+++ b/plugins/impex/tiff/kis_tiff_import.cc
@@ -1840,7 +1840,11 @@ KisTIFFImport::convert(KisDocument *document,
try {
KisExiv2IODevice::ptr_type basicIoDevice(new KisExiv2IODevice(filename()));
+#if EXIV2_TEST_VERSION(0,28,0)
+ const std::unique_ptr<Exiv2::Image> readImg = Exiv2::ImageFactory::open(std::move(basicIoDevice));
+#else
const std::unique_ptr<Exiv2::Image> readImg(Exiv2::ImageFactory::open(basicIoDevice).release());
+#endif
readImg->readMetadata();
@@ -1908,8 +1912,13 @@ KisTIFFImport::convert(KisDocument *document,
// Inject the data as any other IOBackend
io->loadFrom(layer->metaData(), &ioDevice);
+#if EXIV2_TEST_VERSION(0,28,0)
+ } catch (Exiv2::Error &e) {
+ errFile << "Failed metadata import:" << Exiv2::Error(e.code()).what();
+#else
} catch (Exiv2::AnyError &e) {
errFile << "Failed metadata import:" << e.code() << e.what();
+#endif
}
}
diff --git a/plugins/metadata/common/KisExiv2IODevice.cpp b/plugins/metadata/common/KisExiv2IODevice.cpp
index c62e2d1..bf5cdc2 100644
--- a/plugins/metadata/common/KisExiv2IODevice.cpp
+++ b/plugins/metadata/common/KisExiv2IODevice.cpp
@@ -39,7 +39,11 @@ int KisExiv2IODevice::close()
return 0;
}
+#if EXIV2_TEST_VERSION(0,28,0)
+size_t KisExiv2IODevice::write(const Exiv2::byte *data, size_t wcount)
+#else
long KisExiv2IODevice::write(const Exiv2::byte *data, long wcount)
+#endif
{
if (!m_file.isWritable()) {
qWarning() << "KisExiv2IODevice: File not open for writing.";
@@ -53,7 +57,11 @@ long KisExiv2IODevice::write(const Exiv2::byte *data, long wcount)
return 0;
}
+#if EXIV2_TEST_VERSION(0,28,0)
+size_t KisExiv2IODevice::write(Exiv2::BasicIo &src)
+#else
long KisExiv2IODevice::write(Exiv2::BasicIo &src)
+#endif
{
if (static_cast<BasicIo *>(this) == &src) {
return 0;
@@ -88,15 +96,28 @@ int KisExiv2IODevice::putb(Exiv2::byte data)
}
}
+#if EXIV2_TEST_VERSION(0,28,0)
+Exiv2::DataBuf KisExiv2IODevice::read(size_t rcount)
+#else
Exiv2::DataBuf KisExiv2IODevice::read(long rcount)
+#endif
{
Exiv2::DataBuf buf(rcount);
+#if EXIV2_TEST_VERSION(0,28,0)
+ const size_t readCount = read(buf.data(), buf.size());
+ buf.resize(readCount);
+#else
const long readCount = read(buf.pData_, buf.size_);
buf.size_ = readCount;
+#endif
return buf;
}
+#if EXIV2_TEST_VERSION(0,28,0)
+size_t KisExiv2IODevice::read(Exiv2::byte *buf, size_t rcount)
+#else
long KisExiv2IODevice::read(Exiv2::byte *buf, long rcount)
+#endif
{
const qint64 bytesRead = m_file.read(reinterpret_cast<char *>(buf), rcount);
if (bytesRead > 0) {
@@ -202,7 +223,18 @@ int KisExiv2IODevice::munmap()
return 0;
}
+#if EXIV2_TEST_VERSION(0,28,0)
+void KisExiv2IODevice::populateFakeData()
+{
+ return;
+}
+#endif
+
+#if EXIV2_TEST_VERSION(0,28,0)
+size_t KisExiv2IODevice::tell() const
+#else
long KisExiv2IODevice::tell() const
+#endif
{
return m_file.pos();
}
@@ -231,7 +263,11 @@ bool KisExiv2IODevice::eof() const
return m_file.atEnd();
}
+#if EXIV2_TEST_VERSION(0,28,0)
+const std::string& KisExiv2IODevice::path() const noexcept
+#else
std::string KisExiv2IODevice::path() const
+#endif
{
return filePathQString().toStdString();
}
diff --git a/plugins/metadata/common/KisExiv2IODevice.h b/plugins/metadata/common/KisExiv2IODevice.h
index d90831e..27f5f8d 100644
--- a/plugins/metadata/common/KisExiv2IODevice.h
+++ b/plugins/metadata/common/KisExiv2IODevice.h
@@ -18,18 +18,30 @@
class KRITAEXIFCOMMON_EXPORT KisExiv2IODevice : public Exiv2::BasicIo
{
public:
+#if EXIV2_TEST_VERSION(0,28,0)
+ using ptr_type = Exiv2::BasicIo::UniquePtr;
+#else
using ptr_type = Exiv2::BasicIo::AutoPtr;
+#endif
KisExiv2IODevice(QString path);
~KisExiv2IODevice() override;
int open() override;
int close() override;
+#if EXIV2_TEST_VERSION(0,28,0)
+ size_t write(const Exiv2::byte *data, size_t wcount) override;
+ size_t write(Exiv2::BasicIo &src) override;
+ int putb(Exiv2::byte data) override;
+ Exiv2::DataBuf read(size_t rcount) override;
+ size_t read(Exiv2::byte *buf, size_t rcount) override;
+#else
long write(const Exiv2::byte *data, long wcount) override;
long write(Exiv2::BasicIo &src) override;
int putb(Exiv2::byte data) override;
Exiv2::DataBuf read(long rcount) override;
long read(Exiv2::byte *buf, long rcount) override;
+#endif
int getb() override;
void transfer(BasicIo &src) override;
#if defined(_MSC_VER)
@@ -39,13 +51,24 @@ public:
#endif
Exiv2::byte *mmap(bool isWriteable = false) override;
+#if EXIV2_TEST_VERSION(0,28,0)
+ void populateFakeData() override;
+#endif
int munmap() override;
+#if EXIV2_TEST_VERSION(0,28,0)
+ size_t tell() const override;
+#else
long tell() const override;
+#endif
size_t size() const override;
bool isopen() const override;
int error() const override;
bool eof() const override;
+#if EXIV2_TEST_VERSION(0,28,0)
+ const std::string& path() const noexcept override;
+#else
std::string path() const override;
+#endif
private:
bool open(QFile::OpenMode mode);
diff --git a/plugins/metadata/common/kis_exiv2_common.h b/plugins/metadata/common/kis_exiv2_common.h
index 3ab34bb..b4912c7 100644
--- a/plugins/metadata/common/kis_exiv2_common.h
+++ b/plugins/metadata/common/kis_exiv2_common.h
@@ -19,9 +19,11 @@
// Convert an exiv value to a KisMetaData value
inline KisMetaData::Value
-exivValueToKMDValue(const Exiv2::Value::AutoPtr value,
- bool forceSeq,
- KisMetaData::Value::ValueType arrayType = KisMetaData::Value::UnorderedArray)
+#if EXIV2_TEST_VERSION(0,28,0)
+exivValueToKMDValue(const Exiv2::Value::UniquePtr &value, bool forceSeq, KisMetaData::Value::ValueType arrayType = KisMetaData::Value::UnorderedArray)
+#else
+ exivValueToKMDValue(const Exiv2::Value::AutoPtr &value, bool forceSeq, KisMetaData::Value::ValueType arrayType = KisMetaData::Value::UnorderedArray)
+#endif
{
switch (value->typeId()) {
case Exiv2::signedByte:
@@ -42,11 +44,19 @@ exivValueToKMDValue(const Exiv2::Value::AutoPtr value,
case Exiv2::signedShort:
case Exiv2::signedLong: {
if (value->count() == 1 && !forceSeq) {
- return KisMetaData::Value((int)value->toLong());
+#if EXIV2_TEST_VERSION(0,28,0)
+ return {static_cast<int>(value->toUint32())};
+#else
+ return {static_cast<int>(value->toLong())};
+#endif
} else {
QList<KisMetaData::Value> array;
for (int i = 0; i < value->count(); i++)
+#if EXIV2_TEST_VERSION(0,28,0)
+ array.push_back(KisMetaData::Value((int)value->toUint32(i)));
+#else
array.push_back(KisMetaData::Value((int)value->toLong(i)));
+#endif
return KisMetaData::Value(array, arrayType);
}
}
@@ -63,7 +73,11 @@ exivValueToKMDValue(const Exiv2::Value::AutoPtr value,
return {KisMetaData::Rational(value->toRational().first, value->toRational().second)};
} else {
QList<KisMetaData::Value> array;
+#if EXIV2_TEST_VERSION(0,28,0)
+ for (size_t i = 0; i < value->count(); i++) {
+#else
for (long i = 0; i < value->count(); i++) {
+#endif
array.push_back(KisMetaData::Rational(value->toRational(i).first, value->toRational(i).second));
}
return KisMetaData::Value(array, arrayType);
@@ -77,7 +91,11 @@ exivValueToKMDValue(const Exiv2::Value::AutoPtr value,
return KisMetaData::Value(KisMetaData::Rational(value->toRational().first, value->toRational().second));
} else {
QList<KisMetaData::Value> array;
+#if EXIV2_TEST_VERSION(0,28,0)
+ for (size_t i = 0; i < value->count(); i++) {
+#else
for (long i = 0; i < value->count(); i++) {
+#endif
array.push_back(KisMetaData::Rational(value->toRational(i).first, value->toRational(i).second));
}
return KisMetaData::Value(array, arrayType);
diff --git a/plugins/metadata/exif/kis_exif_io.cpp b/plugins/metadata/exif/kis_exif_io.cpp
index 4469712..6afdf75 100644
--- a/plugins/metadata/exif/kis_exif_io.cpp
+++ b/plugins/metadata/exif/kis_exif_io.cpp
@@ -31,7 +31,11 @@
// ---- Exception conversion functions ---- //
// convert ExifVersion and FlashpixVersion to a KisMetaData value
+#if EXIV2_TEST_VERSION(0,28,0)
+KisMetaData::Value exifVersionToKMDValue(const Exiv2::Value::UniquePtr value)
+#else
KisMetaData::Value exifVersionToKMDValue(const Exiv2::Value::AutoPtr value)
+#endif
{
const Exiv2::DataValue *dvalue = dynamic_cast<const Exiv2::DataValue *>(&*value);
if (dvalue) {
@@ -55,13 +59,22 @@ Exiv2::Value *kmdValueToExifVersion(const KisMetaData::Value &value)
}
// Convert an exif array of integer string to a KisMetaData array of integer
+#if EXIV2_TEST_VERSION(0,28,0)
+KisMetaData::Value exifArrayToKMDIntOrderedArray(const Exiv2::Value::UniquePtr value)
+#else
KisMetaData::Value exifArrayToKMDIntOrderedArray(const Exiv2::Value::AutoPtr value)
+#endif
{
QList<KisMetaData::Value> v;
const Exiv2::DataValue *dvalue = dynamic_cast<const Exiv2::DataValue *>(&*value);
if (dvalue) {
+#if EXIV2_TEST_VERSION(0,28,0)
+ for (size_t i = 0; i < dvalue->count(); i++) {
+ v.push_back({(int)dvalue->toUint32(i)});
+#else
for (long i = 0; i < dvalue->count(); i++) {
v.push_back({(int)dvalue->toLong(i)});
+#endif
}
} else {
Q_ASSERT(value->typeId() == Exiv2::asciiString);
@@ -81,7 +94,11 @@ Exiv2::Value *kmdIntOrderedArrayToExifArray(const KisMetaData::Value &value)
return new Exiv2::DataValue(v.data(), static_cast<long>(v.size()));
}
+#if EXIV2_TEST_VERSION(0,28,0)
+QDateTime exivValueToDateTime(const Exiv2::Value::UniquePtr value)
+#else
QDateTime exivValueToDateTime(const Exiv2::Value::AutoPtr value)
+#endif
{
return QDateTime::fromString(value->toString().c_str(), Qt::ISODate);
}
@@ -115,7 +132,11 @@ Exiv2::ByteOrder invertByteOrder(Exiv2::ByteOrder order)
return Exiv2::invalidByteOrder;
}
+#if EXIV2_TEST_VERSION(0,28,0)
+KisMetaData::Value exifOECFToKMDOECFStructure(const Exiv2::Value::UniquePtr value, Exiv2::ByteOrder order)
+#else
KisMetaData::Value exifOECFToKMDOECFStructure(const Exiv2::Value::AutoPtr value, Exiv2::ByteOrder order)
+#endif
{
QMap<QString, KisMetaData::Value> oecfStructure;
const Exiv2::DataValue *dvalue = dynamic_cast<const Exiv2::DataValue *>(&*value);
@@ -123,22 +144,39 @@ KisMetaData::Value exifOECFToKMDOECFStructure(const Exiv2::Value::AutoPtr value,
QByteArray array(dvalue->count(), 0);
dvalue->copy((Exiv2::byte *)array.data());
+#if EXIV2_TEST_VERSION(0,28,0)
+ size_t columns = fixEndianess<qsizetype>((reinterpret_cast<qsizetype *>(array.data()))[0], order);
+ size_t rows = fixEndianess<qsizetype>((reinterpret_cast<qsizetype *>(array.data()))[1], order);
+#else
int columns = fixEndianess<quint16>((reinterpret_cast<quint16 *>(array.data()))[0], order);
int rows = fixEndianess<quint16>((reinterpret_cast<quint16 *>(array.data()))[1], order);
+#endif
if ((columns * rows + 4)
> dvalue->count()) { // Sometime byteOrder get messed up (especially if metadata got saved with kexiv2 library,
// or any library that doesn't save back with the same byte order as the camera)
order = invertByteOrder(order);
+#if EXIV2_TEST_VERSION(0,28,0)
+ columns = fixEndianess<qsizetype>((reinterpret_cast<qsizetype *>(array.data()))[0], order);
+ rows = fixEndianess<qsizetype>((reinterpret_cast<qsizetype *>(array.data()))[1], order);
+#else
columns = fixEndianess<quint16>((reinterpret_cast<quint16 *>(array.data()))[0], order);
rows = fixEndianess<quint16>((reinterpret_cast<quint16 *>(array.data()))[1], order);
+#endif
Q_ASSERT((columns * rows + 4) > dvalue->count());
}
- oecfStructure["Columns"] = KisMetaData::Value(columns);
- oecfStructure["Rows"] = KisMetaData::Value(rows);
+ QVariant qcolumns, qrows;
+ qcolumns.setValue(columns);
+ qrows.setValue(rows);
+ oecfStructure["Columns"] = KisMetaData::Value(qcolumns);
+ oecfStructure["Rows"] = KisMetaData::Value(qrows);
int index = 4;
QList<KisMetaData::Value> names;
+#if EXIV2_TEST_VERSION(0,28,0)
+ for (size_t i = 0; i < columns; i++) {
+#else
for (int i = 0; i < columns; i++) {
+#endif
int lastIndex = array.indexOf((char)0, index);
QString name = array.mid(index, lastIndex - index);
if (index != lastIndex) {
@@ -153,8 +191,13 @@ KisMetaData::Value exifOECFToKMDOECFStructure(const Exiv2::Value::AutoPtr value,
oecfStructure["Names"] = KisMetaData::Value(names, KisMetaData::Value::OrderedArray);
QList<KisMetaData::Value> values;
qint32 *dataIt = reinterpret_cast<qint32 *>(array.data() + index);
+#if EXIV2_TEST_VERSION(0,28,0)
+ for (size_t i = 0; i < columns; i++) {
+ for (size_t j = 0; j < rows; j++) {
+#else
for (int i = 0; i < columns; i++) {
for (int j = 0; j < rows; j++) {
+#endif
values.append(KisMetaData::Value(
KisMetaData::Rational(fixEndianess<qint32>(dataIt[0], order), fixEndianess<qint32>(dataIt[1], order))));
dataIt += 2;
@@ -202,7 +245,11 @@ Exiv2::Value *kmdOECFStructureToExifOECF(const KisMetaData::Value &value)
return new Exiv2::DataValue((const Exiv2::byte *)array.data(), array.size());
}
+#if EXIV2_TEST_VERSION(0,28,0)
+KisMetaData::Value deviceSettingDescriptionExifToKMD(const Exiv2::Value::UniquePtr value)
+#else
KisMetaData::Value deviceSettingDescriptionExifToKMD(const Exiv2::Value::AutoPtr value)
+#endif
{
QMap<QString, KisMetaData::Value> deviceSettingStructure;
QByteArray array;
@@ -258,15 +305,24 @@ Exiv2::Value *deviceSettingDescriptionKMDToExif(const KisMetaData::Value &value)
return new Exiv2::DataValue((const Exiv2::byte *)array.data(), array.size());
}
+#if EXIV2_TEST_VERSION(0,28,0)
+KisMetaData::Value cfaPatternExifToKMD(const Exiv2::Value::UniquePtr value, Exiv2::ByteOrder order)
+#else
KisMetaData::Value cfaPatternExifToKMD(const Exiv2::Value::AutoPtr value, Exiv2::ByteOrder order)
+#endif
{
QMap<QString, KisMetaData::Value> cfaPatternStructure;
const Exiv2::DataValue *dvalue = dynamic_cast<const Exiv2::DataValue *>(&*value);
Q_ASSERT(dvalue);
QByteArray array(dvalue->count(), 0);
dvalue->copy((Exiv2::byte *)array.data());
+#if EXIV2_TEST_VERSION(0,28,0)
+ size_t columns = fixEndianess<qsizetype>((reinterpret_cast<qsizetype *>(array.data()))[0], order);
+ size_t rows = fixEndianess<qsizetype>((reinterpret_cast<qsizetype *>(array.data()))[1], order);
+#else
int columns = fixEndianess<quint16>((reinterpret_cast<quint16 *>(array.data()))[0], order);
int rows = fixEndianess<quint16>((reinterpret_cast<quint16 *>(array.data()))[1], order);
+#endif
if ((columns * rows + 4)
!= dvalue->count()) { // Sometime byteOrder get messed up (especially if metadata got saved with kexiv2 library,
// or any library that doesn't save back with the same byte order as the camera)
@@ -275,8 +331,11 @@ KisMetaData::Value cfaPatternExifToKMD(const Exiv2::Value::AutoPtr value, Exiv2:
rows = fixEndianess<quint16>((reinterpret_cast<quint16 *>(array.data()))[1], order);
Q_ASSERT((columns * rows + 4) == dvalue->count());
}
- cfaPatternStructure["Columns"] = KisMetaData::Value(columns);
- cfaPatternStructure["Rows"] = KisMetaData::Value(rows);
+ QVariant qcolumns, qrows;
+ qcolumns.setValue(columns);
+ qrows.setValue(rows);
+ cfaPatternStructure["Columns"] = KisMetaData::Value(qcolumns);
+ cfaPatternStructure["Rows"] = KisMetaData::Value(qrows);
QList<KisMetaData::Value> values;
int index = 4;
for (int i = 0; i < columns * rows; i++) {
@@ -310,9 +369,17 @@ Exiv2::Value *cfaPatternKMDToExif(const KisMetaData::Value &value)
// Read and write Flash //
+#if EXIV2_TEST_VERSION(0,28,0)
+KisMetaData::Value flashExifToKMD(const Exiv2::Value::UniquePtr value)
+#else
KisMetaData::Value flashExifToKMD(const Exiv2::Value::AutoPtr value)
+#endif
{
+#if EXIV2_TEST_VERSION(0,28,0)
+ const uint16_t v = static_cast<uint16_t>(value->toUint32());
+#else
const uint16_t v = static_cast<uint16_t>(value->toLong());
+#endif
QMap<QString, KisMetaData::Value> flashStructure;
bool fired = (v & 0x01); // bit 1 is whether flash was fired or not
flashStructure["Fired"] = QVariant(fired);
@@ -465,7 +532,11 @@ bool KisExifIO::saveTo(KisMetaData::Store *store, QIODevice *ioDevice, HeaderTyp
<< exivKey; // << " of KMD value" << entry.value();
}
}
+#if EXIV2_TEST_VERSION(0,28,0)
+ } catch (Exiv2::Error &e) {
+#else
} catch (Exiv2::AnyError &e) {
+#endif
dbgMetaData << "exiv error " << e.what();
}
}
diff --git a/plugins/metadata/iptc/kis_iptc_io.cpp b/plugins/metadata/iptc/kis_iptc_io.cpp
index 05f66ee..06f91ed 100644
--- a/plugins/metadata/iptc/kis_iptc_io.cpp
+++ b/plugins/metadata/iptc/kis_iptc_io.cpp
@@ -110,7 +110,11 @@ bool KisIptcIO::saveTo(KisMetaData::Store *store, QIODevice *ioDevice, HeaderTyp
if (v && v->typeId() != Exiv2::invalidTypeId) {
iptcData.add(iptcKey, v);
}
+#if EXIV2_TEST_VERSION(0,28,0)
+ } catch (Exiv2::Error &e) {
+#else
} catch (Exiv2::AnyError &e) {
+#endif
dbgMetaData << "exiv error " << e.what();
}
}
@@ -128,7 +132,11 @@ bool KisIptcIO::saveTo(KisMetaData::Store *store, QIODevice *ioDevice, HeaderTyp
header.append(photoshopBimId_);
header.append(photoshopIptc_);
header.append(QByteArray(2, 0));
+#if EXIV2_TEST_VERSION(0, 28, 0)
+ qint32 size = rawData.size();
+#else
qint32 size = rawData.size_;
+#endif
QByteArray sizeArray(4, 0);
sizeArray[0] = (char)((size & 0xff000000) >> 24);
sizeArray[1] = (char)((size & 0x00ff0000) >> 16);
@@ -138,7 +146,11 @@ bool KisIptcIO::saveTo(KisMetaData::Store *store, QIODevice *ioDevice, HeaderTyp
ioDevice->write(header);
}
+#if EXIV2_TEST_VERSION(0, 28, 0)
+ ioDevice->write((const char *)rawData.data(), rawData.size());
+#else
ioDevice->write((const char *)rawData.pData_, rawData.size_);
+#endif
ioDevice->close();
return true;
}
diff --git a/plugins/metadata/xmp/kis_xmp_io.cpp b/plugins/metadata/xmp/kis_xmp_io.cpp
index 14990de..afb6aa9 100644
--- a/plugins/metadata/xmp/kis_xmp_io.cpp
+++ b/plugins/metadata/xmp/kis_xmp_io.cpp
@@ -248,8 +248,11 @@ bool KisXMPIO::loadFrom(KisMetaData::Store *store, QIODevice *ioDevice) const
Q_ASSERT(schema);
}
}
+#if EXIV2_TEST_VERSION(0,28,0)
+ const Exiv2::Value::UniquePtr value = it->getValue();
+#else
const Exiv2::Value::AutoPtr value = it->getValue();
-
+#endif
QString structName;
int arrayIndex = -1;
QString tagName;
@@ -278,7 +281,11 @@ bool KisXMPIO::loadFrom(KisMetaData::Store *store, QIODevice *ioDevice) const
const Exiv2::XmpArrayValue *xav = dynamic_cast<const Exiv2::XmpArrayValue *>(value.get());
Q_ASSERT(xav);
QList<KisMetaData::Value> array;
+#if EXIV2_TEST_VERSION(0,28,0)
+ for (size_t i = 0; i < xav->count(); ++i) {
+#else
for (int i = 0; i < xav->count(); ++i) {
+#endif
QString value = QString::fromStdString(xav->toString(i));
if (parser) {
array.push_back(parser->parse(value));
--
2.41.0

View File

@ -0,0 +1,45 @@
From 92a643544928c056a1192cd903e0c6666fd2f8c9 Mon Sep 17 00:00:00 2001
From: psykose -- <alice@ayaya.dev>
Date: Thu, 15 Jun 2023 08:48:43 +0000
Subject: [PATCH] KisExiv2IoDevice: fix types on 32-bit host with exiv2 0.28
upstream commit
https://github.com/Exiv2/exiv2/commit/813566526c9ecdc92fc55c7a7d4de2d8e73e125a
now uses int64_t instead of long
this worked for 64-bit ILP64 since long was int64_t, but it does not
match on 32-bit platforms
---
plugins/metadata/common/KisExiv2IODevice.cpp | 2 +-
plugins/metadata/common/KisExiv2IODevice.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/metadata/common/KisExiv2IODevice.cpp b/plugins/metadata/common/KisExiv2IODevice.cpp
index bf5cdc2bd6..ed08543739 100644
--- a/plugins/metadata/common/KisExiv2IODevice.cpp
+++ b/plugins/metadata/common/KisExiv2IODevice.cpp
@@ -175,7 +175,7 @@ void KisExiv2IODevice::transfer(Exiv2::BasicIo &src)
}
}
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) || EXIV2_TEST_VERSION(0,28,0)
int KisExiv2IODevice::seek(int64_t offset, Exiv2::BasicIo::Position position)
#else
int KisExiv2IODevice::seek(long offset, Exiv2::BasicIo::Position position)
diff --git a/plugins/metadata/common/KisExiv2IODevice.h b/plugins/metadata/common/KisExiv2IODevice.h
index 27f5f8d5fc..a72ae01f59 100644
--- a/plugins/metadata/common/KisExiv2IODevice.h
+++ b/plugins/metadata/common/KisExiv2IODevice.h
@@ -44,7 +44,7 @@ public:
#endif
int getb() override;
void transfer(BasicIo &src) override;
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) || EXIV2_TEST_VERSION(0,28,0)
int seek(int64_t offset, Position pos) override;
#else
int seek(long offset, Position pos) override;
--
2.41.0

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Jul 4 07:14:23 UTC 2023 - Christophe Marin <christophe@krop.fr>
- Add patches:
* 0001-Fix-build-with-exiv2-0.28.patch
* 0001-KisExiv2IoDevice-fix-types-on-32-bit-host-with-exiv2.patch
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Jan 16 10:44:28 UTC 2023 - Christophe Marin <christophe@krop.fr> Mon Jan 16 10:44:28 UTC 2023 - Christophe Marin <christophe@krop.fr>