]> www.fi.muni.cz Git - evince.git/commitdiff
Fix crash when opening a pdf with password protection.
authorCarlos Garcia Campos <carlosgc@gnome.org>
Mon, 21 Aug 2006 13:38:28 +0000 (13:38 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Mon, 21 Aug 2006 13:38:28 +0000 (13:38 +0000)
2006-08-21  Carlos Garcia Campos  <carlosgc@gnome.org>
* backend/ev-document-factory.c: (ev_document_factory_get_document):
Fix crash when opening a pdf with password protection.

ChangeLog
backend/ev-document-factory.c

index ae76c6423c0353198d3c344c7eaaeca6a970daab..383cd5be35e1042d00ab95687640f55bf54cf97a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-08-21  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * backend/ev-document-factory.c: (ev_document_factory_get_document):
+
+       Fix crash when opening a pdf with password protection. 
+
 2006-08-19  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * pdf/ev-poppler.cc: (pdf_document_search_free):
index 278a21a1be1976a4531d5b55c620fffc8dc48139..3b3f701a5ce6edf54aa5f7100ab9f833e1705614 100644 (file)
@@ -296,15 +296,21 @@ ev_document_factory_get_document (const char *uri, GError **error)
        }
 
        result = ev_document_load (document, uri, error);
-       
+
        if (result == FALSE || *error) {
-               if (document)
-                       g_object_unref (document);
-               document = NULL;
+               if (*error &&
+                   (*error)->domain == EV_DOCUMENT_ERROR &&
+                   (*error)->code == EV_DOCUMENT_ERROR_ENCRYPTED)
+                       return document;
        } else {
                return document;
        }
 
+       /* Try again with slow mime detection */
+       if (document)
+               g_object_unref (document);
+       document = NULL;
+
        if (*error)
                g_error_free (*error);
        *error = NULL;
@@ -316,20 +322,23 @@ ev_document_factory_get_document (const char *uri, GError **error)
        }
 
        result = ev_document_load (document, uri, error);
-       
-       if (result == FALSE || *error) {
+
+       if (result == FALSE) {
+               if (*error == NULL) {
+                       g_set_error (error,
+                                    EV_DOCUMENT_ERROR,
+                                    0,
+                                    _("Unknown MIME Type"));
+               } else if ((*error)->domain == EV_DOCUMENT_ERROR &&
+                          (*error)->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
+                       return document;
+               }
+
                if (document)
                        g_object_unref (document);
                document = NULL;
        }
-
-       if (result == FALSE && *error == NULL)  {
-               g_set_error (error,
-                            EV_DOCUMENT_ERROR,
-                            0,
-                            _("Unknown MIME Type"));
-       }
-
+       
        return document;
 }