]> www.fi.muni.cz Git - evince.git/commitdiff
More correct handling of document loading. Fixes bug #349043.
authorNickolay V. Shmyrev <nshmyrev@yandex.ru>
Thu, 17 Aug 2006 07:20:47 +0000 (07:20 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Thu, 17 Aug 2006 07:20:47 +0000 (07:20 +0000)
2006-08-17  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>

* backend/ev-document-factory.c:
(ev_document_factory_get_document):
* tiff/tiff-document.c: (tiff_document_finalize):

More correct handling of document loading. Fixes
bug #349043.

ChangeLog
backend/ev-document-factory.c
tiff/tiff-document.c

index 5c9836f46d998a3f638bbf560b829c2b71e8732d..702ddde30b6bb4467269ceee0b8333b42b3ac46f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-08-17  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
+
+       * backend/ev-document-factory.c:
+       (ev_document_factory_get_document):
+       * tiff/tiff-document.c: (tiff_document_finalize):
+       
+       More correct handling of document loading. Fixes
+       bug #349043.
+
 2006-08-14  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * backend/ev-attachment.c: (ev_attachment_save):
index 23364a2db1f5cdddc1a980a8104fba09bf1ad06b..278a21a1be1976a4531d5b55c620fffc8dc48139 100644 (file)
@@ -287,27 +287,48 @@ EvDocument *
 ev_document_factory_get_document (const char *uri, GError **error)
 {
        EvDocument *document;
+       int result;
 
        document = get_document_from_uri (uri, FALSE, error);
 
-       if (*error == NULL) {
-               ev_document_load (document, uri, error);
+       if (*error != NULL) {
+               return NULL;
        }
+
+       result = ev_document_load (document, uri, error);
        
-       if (*error) {
-               g_error_free (*error);
-               *error = NULL;
+       if (result == FALSE || *error) {
+               if (document)
+                       g_object_unref (document);
+               document = NULL;
        } else {
                return document;
        }
 
+       if (*error)
+               g_error_free (*error);
+       *error = NULL;
+
        document = get_document_from_uri (uri, TRUE, error);
 
        if (*error != NULL) {
                return NULL;
        }
 
-       ev_document_load (document, uri, error);
+       result = ev_document_load (document, uri, error);
+       
+       if (result == FALSE || *error) {
+               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;
 }
index 9f465a7c5fc2293aa381cec4e530edc5e30fa259..4a532e19579692b08b555649cf446dcc1998e0b3 100644 (file)
@@ -274,8 +274,10 @@ tiff_document_finalize (GObject *object)
 {
        TiffDocument *tiff_document = TIFF_DOCUMENT (object);
 
-       TIFFClose (tiff_document->tiff);
-       g_free (tiff_document->uri);
+       if (tiff_document->tiff)
+               TIFFClose (tiff_document->tiff);
+       if (tiff_document->uri)
+               g_free (tiff_document->uri);
 
        G_OBJECT_CLASS (tiff_document_parent_class)->finalize (object);
 }