]> www.fi.muni.cz Git - evince.git/commitdiff
Correctly handle impress document errors. Fixes nautilus crash in property
authorTom Parker <palfrey@tevp.net>
Thu, 25 Jan 2007 09:37:16 +0000 (09:37 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Thu, 25 Jan 2007 09:37:16 +0000 (09:37 +0000)
2007-01-25  Tom Parker <palfrey@tevp.net>

* backend/impress/impress-document.c: (impress_document_load),
(impress_document_finalize), (impress_document_init):
* properties/ev-properties-main.c: (ev_properties_get_pages):

Correctly handle impress document errors. Fixes nautilus
crash in property page #370491.

svn path=/trunk/; revision=2250

ChangeLog
backend/impress/impress-document.c
properties/ev-properties-main.c

index 961a68f48bdbae02517ae6a3db6d1c75ac62d59a..2180c319ae2f4912ee125b211ae722ed00cb4f3d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-01-25  Tom Parker <palfrey@tevp.net>
+
+       * backend/impress/impress-document.c: (impress_document_load),
+       (impress_document_finalize), (impress_document_init):
+       * properties/ev-properties-main.c: (ev_properties_get_pages):
+       
+       Correctly handle impress document errors. Fixes nautilus
+       crash in property page #370491.
+
 2007-01-24  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * shell/ev-job-queue.c: (handle_job), (search_for_jobs_unlocked),
index 7459dab168c02f246f9f6906a9d8ca61c8c37559..9756a84d1b383d48ba04a1eff4aca387da78aa52 100644 (file)
@@ -19,7 +19,9 @@
  */
 
 #include <gtk/gtk.h>
+#include <glib/gi18n.h>
 #include <string.h>
+
 #include "imposter.h"
 #include "impress-document.h"
 #include "ev-document-thumbnails.h"
@@ -286,8 +288,10 @@ impress_document_load (EvDocument  *document,
   filename = g_filename_from_uri (uri, NULL, error);
   if (!filename)
     {
-      //FIXME
-      //g_error_set ();
+      g_set_error (error,
+                  EV_DOCUMENT_ERROR,
+                  EV_DOCUMENT_ERROR_INVALID,
+                  _("Remote files aren't supported"));
       return FALSE;
     }
 
@@ -295,7 +299,10 @@ impress_document_load (EvDocument  *document,
 
   if (!imp)
     {
-      //FIXME translate the err, set error
+      g_set_error (error,
+                  EV_DOCUMENT_ERROR,
+                  EV_DOCUMENT_ERROR_INVALID,
+                  _("Invalid document"));
       g_free (filename);
       return FALSE;
     }
@@ -400,13 +407,23 @@ impress_document_finalize (GObject *object)
 {
   ImpressDocument *impress_document = IMPRESS_DOCUMENT (object);
 
-  g_mutex_free (impress_document->mutex);
+  if (impress_document->mutex)
+    g_mutex_free (impress_document->mutex);
+
+  if (impress_document->imp)
+    imp_close (impress_document->imp);
+
+  if (impress_document->ctx)
+    imp_delete_context (impress_document->ctx);
+
+  if (impress_document->pango_ctx)
+    g_object_unref (impress_document->pango_ctx);
+
+  if (impress_document->pixmap)
+    g_object_unref (G_OBJECT (impress_document->pixmap));
 
-  imp_close (impress_document->imp);
-  imp_delete_context (impress_document->ctx);
-  g_free (impress_document->pango_ctx);
-  g_object_unref (G_OBJECT (impress_document->pixmap));
-  g_object_unref (impress_document->gc);
+  if (impress_document->gc)
+    g_object_unref (impress_document->gc);
 
   G_OBJECT_CLASS (impress_document_parent_class)->finalize (object);
 }
@@ -516,7 +533,7 @@ impress_document_init (ImpressDocument *impress_document)
   impress_document->pixmap = gdk_pixmap_new (window,
                                             PAGE_WIDTH, PAGE_HEIGHT, -1);
   impress_document->gc = gdk_gc_new (impress_document->pixmap);
-  impress_document->pango_ctx = gdk_pango_context_get ();
+  impress_document->pango_ctx = gdk_pango_context_get_for_screen (gdk_screen_get_default ());
 }
 
 /*
index 32677fc1839c0c5e1b3e3acd89d6a44ffa1c9cc8..10d1ec8d47325bd45b1e4bb060a1687470950364 100644 (file)
@@ -103,6 +103,9 @@ ev_properties_get_pages (NautilusPropertyPageProvider *provider,
                g_error_free (error);
                goto end;
        }
+       
+       if (!document)
+               goto end;
 
        label = gtk_label_new (_("Document"));
        page = ev_properties_view_new ();