[tracker-miners/wip/carlosg/compiler-warnings: 4/8] tracker-extract: Avoid deprecated poppler API




commit ee60e50ccd34262ee9fdbd83a95a08d992b81ba8
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Aug 28 23:02:04 2022 +0200

    tracker-extract: Avoid deprecated poppler API
    
    Since 0.82, poppler offers API to load a document from GBytes, and prefers
    that over the variant passing data/len. Use that API if building against
    a newer poppler.

 src/tracker-extract/tracker-extract-pdf.c | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/src/tracker-extract/tracker-extract-pdf.c b/src/tracker-extract/tracker-extract-pdf.c
index eb62ddf95..5cfddfbc7 100644
--- a/src/tracker-extract/tracker-extract-pdf.c
+++ b/src/tracker-extract/tracker-extract-pdf.c
@@ -292,6 +292,7 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
        TrackerXmpData *xd = NULL;
        PDFData pd = { 0 }; /* actual data */
        PDFData md = { 0 }; /* for merging */
+       G_GNUC_UNUSED GBytes *bytes;
        PopplerDocument *document;
        gchar *xml = NULL;
        gchar *content, *uri;
@@ -346,7 +347,13 @@ tracker_extract_get_metadata (TrackerExtractInfo  *info,
        g_free (filename);
        uri = g_file_get_uri (file);
 
+#if POPPLER_CHECK_VERSION (0, 82, 0)
+       bytes = g_bytes_new (contents, len);
+       document = poppler_document_new_from_bytes (bytes, NULL, &inner_error);
+       g_bytes_unref (bytes);
+#else
        document = poppler_document_new_from_data (contents, len, NULL, &inner_error);
+#endif
 
        if (inner_error) {
                if (inner_error->code == POPPLER_ERROR_ENCRYPTED) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]