From 6805bdcd6a58d681de0fb569c98efffd32bcae8c Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 18 Aug 2013 10:56:20 +0000 Subject: [PATCH] Don't run toplevel callbacks in modal dialogs. Because some of them can call gtk_main_quit(), which completely confuses the dialog box system. [originally from svn r10029] --- unix/gtkwin.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/unix/gtkwin.c b/unix/gtkwin.c index 59a5c383..29ac2284 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -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;