[gexiv2/wip/fix-exiv2-master] Fix compatibility with exiv2 main branch
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gexiv2/wip/fix-exiv2-master] Fix compatibility with exiv2 main branch
- Date: Sun, 12 Sep 2021 10:01:05 +0000 (UTC)
commit 098464f237606c41e1eace058470f13f10d604c4
Author: Jens Georg <mail jensge org>
Date: Sun Sep 12 11:59:42 2021 +0200
Fix compatibility with exiv2 main branch
gexiv2/gexiv2-metadata.cpp | 35 ++++++++++++++++++++++++++---------
gexiv2/gexiv2-stream-io.cpp | 14 +++++++++-----
gexiv2/meson.build | 2 +-
meson.build | 15 +++++++++++++++
4 files changed, 51 insertions(+), 15 deletions(-)
---
diff --git a/gexiv2/gexiv2-metadata.cpp b/gexiv2/gexiv2-metadata.cpp
index 928b07b..8660ac7 100644
--- a/gexiv2/gexiv2-metadata.cpp
+++ b/gexiv2/gexiv2-metadata.cpp
@@ -9,19 +9,22 @@
*/
#include "gexiv2-metadata.h"
-#include "gexiv2-metadata-private.h"
-#include "gexiv2-stream-io.h"
+
+#include "gexiv2-log-private.h"
+#include "gexiv2-log.h"
#include "gexiv2-managed-stream.h"
-#include "gexiv2-preview-properties.h"
-#include "gexiv2-preview-properties-private.h"
-#include "gexiv2-preview-image.h"
+#include "gexiv2-metadata-private.h"
#include "gexiv2-preview-image-private.h"
-#include "gexiv2-log.h"
-#include "gexiv2-log-private.h"
-#include <string>
+#include "gexiv2-preview-image.h"
+#include "gexiv2-preview-properties-private.h"
+#include "gexiv2-preview-properties.h"
+#include "gexiv2-stream-io.h"
+
#include <cmath>
-#include <glib-object.h>
+#include <config.h>
#include <gio/gio.h>
+#include <glib-object.h>
+#include <string>
#ifdef G_OS_WIN32
#include <glib/gwin32.h>
@@ -91,9 +94,17 @@ public:
Exiv2::DataBuf read(size_type rcount) override {
Exiv2::DataBuf b{rcount};
+#ifdef EXIV2_DATABUF_HAS_PRIVATE_PDATA
+ auto bytes_read = this->read(b.data(), rcount);
+#else
auto bytes_read = this->read(b.pData_, rcount);
+#endif
if (bytes_read > 0 && bytes_read != rcount) {
+#ifdef EXIV2_DATABUF_HAS_PRIVATE_PDATA
+ b.reset({b.data(), bytes_read});
+#else
b.reset({b.pData_, bytes_read});
+#endif
}
return b;
@@ -1691,6 +1702,11 @@ gboolean gexiv2_metadata_get_exif_thumbnail (GExiv2Metadata *self, guint8** buff
g_return_val_if_fail(self->priv->image.get() != nullptr, FALSE);
Exiv2::ExifThumb thumb = Exiv2::ExifThumb(self->priv->image->exifData());
+#ifdef EXIV2_DATABUF_HAS_PRIVATE_PDATA
+ auto data = thumb.copy().release();
+ *buffer = data.first;
+ *size = data.second;
+#else
Exiv2::DataBuf data = thumb.copy();
if (data.pData_ == nullptr)
return FALSE;
@@ -1698,6 +1714,7 @@ gboolean gexiv2_metadata_get_exif_thumbnail (GExiv2Metadata *self, guint8** buff
*buffer = (guint8*) g_malloc(data.size_);
memcpy(*buffer, data.pData_, data.size_);
*size = data.size_;
+#endif
return TRUE;
}
diff --git a/gexiv2/gexiv2-stream-io.cpp b/gexiv2/gexiv2-stream-io.cpp
index 5c755c3..2d500f3 100644
--- a/gexiv2/gexiv2-stream-io.cpp
+++ b/gexiv2/gexiv2-stream-io.cpp
@@ -11,15 +11,16 @@
*/
#include "gexiv2-stream-io.h"
+
#include "gexiv2-managed-stream.h"
+#include <config.h>
+#include <exception>
#include <exiv2/exiv2.hpp>
#include <gio/gio.h>
#include <glib.h>
#include <stdio.h>
-#include <exception>
-
StreamIo::StreamIo (ManagedStreamCallbacks* callbacks)
: cb (callbacks), memio(nullptr), is_open (FALSE), can_write(FALSE) {
/* at least reading and seeking must be possible to read metatada */
@@ -165,11 +166,14 @@ int StreamIo::close () {
Exiv2::DataBuf StreamIo::read (size_type read_count) {
Exiv2::DataBuf buffer (read_count);
-
+#ifdef EXIV2_DATABUF_HAS_PRIVATE_PDATA
+ long read_bytes = read(buffer.data(), read_count);
+ buffer.resize(read_bytes);
+#else
long read_bytes = read (buffer.pData_, buffer.size_);
-
buffer.size_ = read_bytes;
-
+#endif
+
return buffer;
}
diff --git a/gexiv2/meson.build b/gexiv2/meson.build
index ed7c046..ad383ee 100644
--- a/gexiv2/meson.build
+++ b/gexiv2/meson.build
@@ -61,7 +61,7 @@ gexiv2 = library('gexiv2',
'gexiv2-preview-properties-private.h',
'gexiv2-preview-image-private.h'] +
gexiv2_headers +
- [version_header] +
+ [version_header, config_h] +
enum_sources,
include_directories : include_directories('..'),
version: libversion,
diff --git a/meson.build b/meson.build
index e8bae0c..285e079 100644
--- a/meson.build
+++ b/meson.build
@@ -33,6 +33,21 @@ bmff_test = '''#include <exiv2/exiv2.hpp>
bmff_available = cpp.compiles(bmff_test, name : 'BMFF support in exiv2', dependencies : [exiv2])
+private_pdata_test = '''#include <exiv2/exiv2.hpp>
+#include <iostream>
+int main(void) {
+ Exiv2::DataBuf buf;
+ std::cout << buf.c_data() << std::endl;
+}'''
+private_pdata = cpp.compiles(private_pdata_test, name : 'DataBuf is sealead in exiv2', dependencies :
[exiv2])
+
+build_config = configuration_data ()
+build_config.set10('EXIV2_DATABUF_HAS_PRIVATE_PDATA', private_pdata)
+config_h = configure_file(
+ output: 'config.h',
+ configuration: build_config
+)
+
find_program('g-ir-scanner', required: get_option('introspection'))
if get_option('vapi')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]