[gimp] app: file_open_from_command_line(): don't access a dangling display pointer



commit 6c62eb2238d2167ebe20ee02ad32ef733db475b1
Author: Massimo Valentini <mvalentini src gnome org>
Date:   Thu Jul 4 21:05:25 2013 +0200

    app: file_open_from_command_line(): don't access a dangling display pointer
    
    Happens if GIMP is quit while the image is being loaded.

 app/file/file-open.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/app/file/file-open.c b/app/file/file-open.c
index fde3774..63fdf02 100644
--- a/app/file/file-open.c
+++ b/app/file/file-open.c
@@ -614,6 +614,8 @@ file_open_from_command_line (Gimp        *gimp,
       GimpObject        *display = gimp_get_empty_display (gimp);
       GimpPDBStatusType  status;
 
+      g_object_add_weak_pointer (G_OBJECT (display), (gpointer) &display);
+
       image = file_open_with_display (gimp,
                                       gimp_get_user_context (gimp),
                                       GIMP_PROGRESS (display),
@@ -627,7 +629,7 @@ file_open_from_command_line (Gimp        *gimp,
           g_object_set_data_full (G_OBJECT (gimp), GIMP_FILE_OPEN_LAST_URI_KEY,
                                   uri, (GDestroyNotify) g_free);
         }
-      else if (status != GIMP_PDB_CANCEL)
+      else if (status != GIMP_PDB_CANCEL && display)
         {
           gchar *filename = file_utils_uri_display_name (uri);
 
@@ -639,6 +641,9 @@ file_open_from_command_line (Gimp        *gimp,
           g_free (filename);
           g_free (uri);
         }
+
+      if (display)
+        g_object_remove_weak_pointer (G_OBJECT (display), (gpointer) &display);
     }
   else
     {


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