Skip to content

Commit

Permalink
Fix build with >=exiv2-0.28.0, raise minimum to 0.27.0
Browse files Browse the repository at this point in the history
- enables use of EXIV2_TEST_VERSION macro
- add compatibility for exiv2-0.28.0
  • Loading branch information
eclipseo committed Nov 11, 2023
1 parent 4a4c6e8 commit 4abcdaa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ viewnior_deps = [
dependency('gio-2.0', version: glib_ver),
dependency('shared-mime-info', version: '>= 0.20'),
dependency('gdk-pixbuf-2.0', version: '>= 0.21'),
dependency('exiv2', version: '>= 0.21'),
dependency('exiv2', version: '>= 0.27'),
]
#

Expand Down
21 changes: 15 additions & 6 deletions src/uni-exiv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,29 @@

#include <exiv2/exiv2.hpp>
#include <iostream>
#include <memory>

#include "uni-exiv2.hpp"

#if EXIV2_TEST_VERSION(0,28,0)
typedef Exiv2::Error Exiv2::Exiv2Error;
typedef Exiv2::Image::UniquePtr ImagePtr;
#else
typedef Exiv2::AnyError Exiv2::Exiv2Error;
typedef Exiv2::Image::AutoPtr ImagePtr;
#endif

#define ARRAY_SIZE(array) (sizeof array/sizeof(array[0]))

static Exiv2::Image::AutoPtr cached_image;
static ImagePtr cached_image;

extern "C"
void
uni_read_exiv2_map(const char *uri, void (*callback)(const char*, const char*, void*), void *user_data)
{
Exiv2::LogMsg::setLevel(Exiv2::LogMsg::mute);
try {
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(uri);
ImagePtr image = Exiv2::ImageFactory::open(uri);
if ( image.get() == 0 ) {
return;
}
Expand Down Expand Up @@ -80,7 +89,7 @@ uni_read_exiv2_map(const char *uri, void (*callback)(const char*, const char*, v
}
}
}
} catch (Exiv2::AnyError& e) {
} catch (Exiv2Error& e) {
std::cerr << "Exiv2: '" << e << "'\n";
}
}
Expand All @@ -103,7 +112,7 @@ uni_read_exiv2_to_cache(const char *uri)
}

cached_image->readMetadata();
} catch (Exiv2::AnyError& e) {
} catch (Exiv2Error& e) {
std::cerr << "Exiv2: '" << e << "'\n";
}

Expand All @@ -121,7 +130,7 @@ uni_write_exiv2_from_cache(const char *uri)
}

try {
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(uri);
ImagePtr image = Exiv2::ImageFactory::open(uri);
if ( image.get() == 0 ) {
return 2;
}
Expand All @@ -133,7 +142,7 @@ uni_write_exiv2_from_cache(const char *uri)
cached_image.reset(NULL);

return 0;
} catch (Exiv2::AnyError& e) {
} catch (Exiv2Error& e) {
std::cerr << "Exiv2: '" << e << "'\n";
}

Expand Down

0 comments on commit 4abcdaa

Please sign in to comment.