r20698 - gnucash/branches/2.4/src/gnome-utils -  Fix up the Mac shutdown process to give Gnucash a chance to clean up without spewing critical errors about the main loop already running (because of calling gnc_shutdown in an event handler).
cstim at code.gnucash.org
Fri May 27 03:09:11 EDT 2011
Date: 2011-05-27 03:09:11 -0400 (Fri, 27 May 2011)
New Revision: 20698
 Fix up the Mac shutdown process to give Gnucash a chance to clean up without spewing critical errors about the main loop already running (because of calling gnc_shutdown in an event handler).
Original commit by jralls.
--- gnucash/branches/2.4/src/gnome-utils/gnc-main-window.c 2011-05-27 07:04:02 UTC (rev 20697)
+++ gnucash/branches/2.4/src/gnome-utils/gnc-main-window.c 2011-05-27 07:09:11 UTC (rev 20698)
@@ -3372,12 +3372,25 @@
+/* Event handlers for the shutdown process. Gnc_quartz_shutdown is
+ * connected to NSApplicationWillTerminate, the last chance to do
+ * anything before quitting. The problem is that it's launched from a
+ * CFRunLoop, not a g_main_loop, and if we call anything that would
+ * affect the main_loop we get an assert that we're in a subidiary
+ * loop.
gtk_quartz_shutdown (GtkOSXApplication *theApp, gpointer data)
+/* Do Nothing. It's too late. */
+/* Should quit responds to NSApplicationBlockTermination; returning
+ * TRUE means "don't terminate", FALSE means "do terminate". If we
+ * decide that it's OK to terminate, then we queue a gnc_shutdown for
+ * the next idle time (because we're not running in the main loop) and
+ * then tell the OS not to terminate. That gives the gnc_shutdown an
+ * opportunity to shut down.
gtk_quartz_should_quit (GtkOSXApplication *theApp, GncMainWindow *window)
@@ -3392,8 +3405,9 @@
if (needs_save && gnc_main_window_prompt_for_save(GTK_WIDGET(window)))
- return FALSE;
+ g_idle_add((GSourceFunc)gnc_shutdown, 0);
+ return TRUE;
More information about the gnucash-changes