]> asedeno.scripts.mit.edu Git - PuTTY_svn.git/commitdiff
Don't run toplevel callbacks in modal dialogs.
authorSimon Tatham <anakin@pobox.com>
Sun, 18 Aug 2013 10:56:20 +0000 (10:56 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 18 Aug 2013 10:56:20 +0000 (10:56 +0000)
Because some of them can call gtk_main_quit(), which completely
confuses the dialog box system.

git-svn-id: http://svn.tartarus.org/sgt/putty@10029 cda61777-01e9-0310-a592-d414129be87e

unix/gtkwin.c

index 59a5c383a8f8c4d0f272cfd0d2b4694b02cf95a1..29ac22844e6a40bbc24b9a88fb9c77d84703b081 100644 (file)
@@ -1395,18 +1395,39 @@ void notify_remote_exit(void *frontend)
     queue_toplevel_callback(exit_callback, inst);
 }
 
+static void notify_toplevel_callback(void *frontend);
+
+static gint quit_toplevel_callback_func(gpointer data)
+{
+    struct gui_data *inst = (struct gui_data *)data;
+
+    notify_toplevel_callback(inst);
+
+    return 0;
+}
+
 static gint idle_toplevel_callback_func(gpointer data)
 {
     struct gui_data *inst = (struct gui_data *)data;
 
-    run_toplevel_callbacks();
+    if (gtk_main_level() > 1) {
+        /*
+         * We don't run the callbacks if we're in the middle of a
+         * subsidiary gtk_main. Instead, ask for a callback when we
+         * get back out of the subsidiary main loop, so we can
+         * reschedule ourself then.
+         */
+        gtk_quit_add(2, quit_toplevel_callback_func, inst);
+    } else {
+        run_toplevel_callbacks();
+    }
 
     gtk_idle_remove(inst->toplevel_callback_idle_id);
 
     return TRUE;
 }
 
-void notify_toplevel_callback(void *frontend)
+static void notify_toplevel_callback(void *frontend)
 {
     struct gui_data *inst = (struct gui_data *)frontend;