[gimp/gimp-2-8] Bug 629941 - GIMP doesn't exit properly when quitting while loading images



commit 4e664a011d5b5142c65dd813ee3cb4a324e97ac6
Author: Massimo Valentini <mvalentini src gnome org>
Date:   Thu Jul 4 21:36:40 2013 +0200

    Bug 629941 - GIMP doesn't exit properly when quitting while loading images
    
    GIMP's "exit" signal was emitted before the handler was connected.
    
    Don't start loading command line images or batch processing before
    app_exit_after_callback() is connected. Make sure we don't use
    dangling main loop pointers or try to stop a non-running main loop.
    
    (cherry picked from commit 09682d62ae675125e91d537c3ccbdd4571a0b28e)

 app/app.c |   53 ++++++++++++++++++++++++++++++++---------------------
 1 files changed, 32 insertions(+), 21 deletions(-)
---
diff --git a/app/app.c b/app/app.c
index e6b7407..dbbc1b3 100644
--- a/app/app.c
+++ b/app/app.c
@@ -72,12 +72,12 @@
 
 /*  local prototypes  */
 
-static void       app_init_update_noop    (const gchar *text1,
-                                           const gchar *text2,
-                                           gdouble      percentage);
-static gboolean   app_exit_after_callback (Gimp        *gimp,
-                                           gboolean     kill_it,
-                                           GMainLoop   *loop);
+static void       app_init_update_noop    (const gchar  *text1,
+                                           const gchar  *text2,
+                                           gdouble       percentage);
+static gboolean   app_exit_after_callback (Gimp         *gimp,
+                                           gboolean      kill_it,
+                                           GMainLoop   **loop);
 
 
 /*  public functions  */
@@ -149,6 +149,7 @@ app_run (const gchar         *full_prog_name,
   Gimp               *gimp;
   GimpBaseConfig     *config;
   GMainLoop          *loop;
+  GMainLoop          *run_loop;
   gboolean            swap_is_ok;
 
   /*  Create an instance of the "Gimp" object which is the root of the
@@ -234,6 +235,12 @@ app_run (const gchar         *full_prog_name,
    */
   gimp_rc_set_autosave (GIMP_RC (gimp->edit_config), TRUE);
 
+  loop = run_loop = g_main_loop_new (NULL, FALSE);
+
+  g_signal_connect_after (gimp, "exit",
+                          G_CALLBACK (app_exit_after_callback),
+                          &run_loop);
+
   /*  Load the images given on the command-line.
    */
   if (filenames)
@@ -241,20 +248,21 @@ app_run (const gchar         *full_prog_name,
       gint i;
 
       for (i = 0; filenames[i] != NULL; i++)
-        file_open_from_command_line (gimp, filenames[i], as_new);
+        {
+          if (run_loop)
+            file_open_from_command_line (gimp, filenames[i], as_new);
+        }
     }
 
-  batch_run (gimp, batch_interpreter, batch_commands);
-
-  loop = g_main_loop_new (NULL, FALSE);
+  if (run_loop)
+    batch_run (gimp, batch_interpreter, batch_commands);
 
-  g_signal_connect_after (gimp, "exit",
-                          G_CALLBACK (app_exit_after_callback),
-                          loop);
-
-  gimp_threads_leave (gimp);
-  g_main_loop_run (loop);
-  gimp_threads_enter (gimp);
+  if (run_loop)
+    {
+      gimp_threads_leave (gimp);
+      g_main_loop_run (loop);
+      gimp_threads_enter (gimp);
+    }
 
   g_main_loop_unref (loop);
 
@@ -279,9 +287,9 @@ app_init_update_noop (const gchar *text1,
 }
 
 static gboolean
-app_exit_after_callback (Gimp      *gimp,
-                         gboolean   kill_it,
-                         GMainLoop *loop)
+app_exit_after_callback (Gimp       *gimp,
+                         gboolean    kill_it,
+                         GMainLoop **loop)
 {
   if (gimp->be_verbose)
     g_print ("EXIT: %s\n", G_STRFUNC);
@@ -297,7 +305,10 @@ app_exit_after_callback (Gimp      *gimp,
 
 #ifdef GIMP_UNSTABLE
 
-  g_main_loop_quit (loop);
+  if (g_main_loop_is_running (*loop))
+    g_main_loop_quit (*loop);
+
+  *loop = NULL;
 
 #else
 


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