[gimp] app: when opening an image, don't unref it if no display could be created



commit a75a9d94696474f6c7cc1c101ef16bc67886553e
Author: Michael Natterer <mitch gimp org>
Date:   Tue May 17 14:55:57 2011 +0200

    app: when opening an image, don't unref it if no display could be created
    
    we normally do this because the initial display takes ownership of the
    newly created image, but in no-interface mode we would simply unref
    the image away, which is bad.

 app/file/file-open.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/app/file/file-open.c b/app/file/file-open.c
index 4982f81..b662cf4 100644
--- a/app/file/file-open.c
+++ b/app/file/file-open.c
@@ -423,7 +423,11 @@ file_open_with_proc_and_display (Gimp                *gimp,
           g_free (basename);
         }
 
-      gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0);
+      if (gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0))
+        {
+          /*  the display owns the image now  */
+          g_object_unref (image);
+        }
 
       if (! as_new)
         {
@@ -445,9 +449,6 @@ file_open_with_proc_and_display (Gimp                *gimp,
             }
         }
 
-      /*  the display owns the image now  */
-      g_object_unref (image);
-
       /*  announce that we opened this image  */
       gimp_image_opened (image->gimp, uri);
     }



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