[evince/gnome-3-30] ev-document-factory: fix get_backend_info_for_mime_type for macOS and Windows



commit 8976e0d7faf025c0b53839b4bb5926a3895779a7
Author: Tom Schoonjans <Tom Schoonjans diamond ac uk>
Date:   Fri Apr 26 19:41:18 2019 +0100

    ev-document-factory: fix get_backend_info_for_mime_type for macOS and Windows
    
    This patch fixes opening files when Evince is built against GLib
    containing GContentType implementations for non-Linux operating systems
    such as macOS and Windows. On such platforms content type is not equal
    to mime type, as stipulated in the GContentType documentation.

 libdocument/ev-document-factory.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/libdocument/ev-document-factory.c b/libdocument/ev-document-factory.c
index ca1aeeb4..ffe180ca 100644
--- a/libdocument/ev-document-factory.c
+++ b/libdocument/ev-document-factory.c
@@ -51,6 +51,7 @@ static EvBackendInfo *
 get_backend_info_for_mime_type (const gchar *mime_type)
 {
         GList *l;
+        gchar *content_type = g_content_type_from_mime_type (mime_type);
 
         for (l = ev_backends_list; l; l = l->next) {
                 EvBackendInfo *info = (EvBackendInfo *) l->data;
@@ -58,11 +59,14 @@ get_backend_info_for_mime_type (const gchar *mime_type)
                 guint i;
 
                 for (i = 0; mime_types[i] != NULL; ++i) {
-                        if (g_content_type_is_mime_type (mime_type, mime_types[i]))
+                        if (g_content_type_is_mime_type (content_type, mime_types[i])) {
+                                g_free (content_type);
                                 return info;
+                        }
                 }
         }
 
+        g_free (content_type);
         return NULL;
 }
 


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