#include "main.h"
#include "exif.h"
+#include "filedata.h"
#include "filefilter.h"
-#include "ui-fileops.h"
-
#include "misc.h"
+#include "ui-fileops.h"
#if EXIV2_TEST_VERSION(0,28,0)
#define AnyError Error
virtual ~ExifData() = default;
- virtual void writeMetadata(gchar *UNUSED(path) = nullptr)
+ virtual void writeMetadata(gchar * = nullptr)
{
g_critical("Unsupported method of writing metadata");
}
try
{
image_ = Exiv2::ImageFactory::open(pathl_);
-// g_assert (image.get() != 0);
image_->readMetadata();
#if EXIV2_TEST_VERSION(0,16,0)
return utf8_validate_or_convert((reinterpret_cast<Exiv2::Metadatum *>(item))->tagLabel().c_str());
}
catch (std::exception& e) {
-// debug_exception(e);
return nullptr;
}
}
}
}
-const char *exif_item_get_format_name(ExifItem *item, gboolean UNUSED(brief))
+const char *exif_item_get_format_name(ExifItem *item, gboolean)
{
try {
if (!item) return nullptr;
Exiv2::PreviewImage image = pm.getPreviewImage(*pos);
- Exiv2::DataBuf buf = image.copy();
-
-#if EXIV2_TEST_VERSION(0,28,0)
- *data_len = buf.size();
- auto b = buf.data();
- buf.reset();
- return b;
-#else
- std::pair<Exiv2::byte*, long> p = buf.release();
-
- *data_len = p.second;
- return p.first;
-#endif
+ // Let's not touch data_len until we finish copy.
+ // Just in case we run into OOM.
+ size_t img_sz = image.size();
+ auto* b = new Exiv2::byte[img_sz];
+ std::copy_n(image.pData(), img_sz, b);
+ *data_len = img_sz;
+ return b;
}
return nullptr;
}
}
}
-void exif_free_preview(guchar *buf)
+void exif_free_preview(const guchar *buf)
{
delete[] static_cast<Exiv2::byte*>(buf);
}