[Gnucash-changes] r13337 - gnucash/trunk - Catch and defer the quit command if a file save is in progress.

David Hampton hampton at cvs.gnucash.org
Mon Feb 20 19:14:00 EST 2006


Author: hampton
Date: 2006-02-20 19:14:00 -0500 (Mon, 20 Feb 2006)
New Revision: 13337
Trac: http://svn.gnucash.org/trac/changeset/13337

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/gnome-utils/gnc-file.c
   gnucash/trunk/src/gnome-utils/gnc-file.h
   gnucash/trunk/src/gnome-utils/gnc-main-window.c
Log:
Catch and defer the quit command if a file save is in progress.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-02-20 22:37:48 UTC (rev 13336)
+++ gnucash/trunk/ChangeLog	2006-02-21 00:14:00 UTC (rev 13337)
@@ -1,5 +1,10 @@
 2006-02-20  David Hampton  <hampton at employees.org>
 
+	* src/gnome-utils/gnc-file.[ch]:
+
+	* src/gnome-utils/gnc-main-window.c: Catch and defer the quit
+	command if a file save is in progress. Fixes 155327.
+
 	* rpm/gnucash.spec.in:
 	* rpm/README: Update spec file from RH8 to FC4.
 

Modified: gnucash/trunk/src/gnome-utils/gnc-file.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-file.c	2006-02-20 22:37:48 UTC (rev 13336)
+++ gnucash/trunk/src/gnome-utils/gnc-file.c	2006-02-21 00:14:00 UTC (rev 13337)
@@ -52,6 +52,7 @@
 static QofLogModule log_module = GNC_MOD_GUI;
 
 static GNCShutdownCB shutdown_cb = NULL;
+static gint save_in_progress = 0;
 
 
 /********************************************************************\
@@ -941,11 +942,13 @@
   }
 
   /* use the current session to save to file */
+  save_in_progress++;
   gnc_set_busy_cursor (NULL, TRUE);
   gnc_window_show_progress(_("Writing file..."), 0.0);
   qof_session_save (session, gnc_window_show_progress);
   gnc_window_show_progress(NULL, -1.0);
   gnc_unset_busy_cursor (NULL);
+  save_in_progress--;
 
   /* Make sure everything's OK - disk could be full, file could have
      become read-only etc. */
@@ -1015,6 +1018,7 @@
 
   /* -- this session code is NOT identical in FileOpen and FileSaveAs -- */
 
+  save_in_progress++;
   new_session = qof_session_new ();
   qof_session_begin (new_session, newfile, FALSE, FALSE);
 
@@ -1053,6 +1057,7 @@
     qof_session_destroy (new_session);
     xaccLogEnable();
     g_free (newfile);
+    save_in_progress--;
     return;
   }
 
@@ -1082,6 +1087,7 @@
     if (!gnc_verify_dialog (NULL, FALSE, format, newfile))
     {
       g_free (newfile);
+      save_in_progress--;
       return;
     }
 
@@ -1089,6 +1095,7 @@
   }
 
   gnc_file_save ();
+  save_in_progress--;
 
   g_free (newfile);
   LEAVE (" ");
@@ -1124,3 +1131,9 @@
 {
   shutdown_cb = cb;
 }
+
+gboolean
+gnc_file_save_in_progress (void)
+{
+  return (save_in_progress > 0);
+}

Modified: gnucash/trunk/src/gnome-utils/gnc-file.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-file.h	2006-02-20 22:37:48 UTC (rev 13336)
+++ gnucash/trunk/src/gnome-utils/gnc-file.h	2006-02-21 00:14:00 UTC (rev 13337)
@@ -150,5 +150,6 @@
 
 typedef void (*GNCShutdownCB) (int);
 void gnc_file_set_shutdown_callback (GNCShutdownCB cb);
+gboolean gnc_file_save_in_progress (void);
 
 #endif /* GNC_FILE_H */

Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c	2006-02-20 22:37:48 UTC (rev 13336)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c	2006-02-21 00:14:00 UTC (rev 13337)
@@ -2677,10 +2677,26 @@
 	}
 }
 
+static gboolean
+gnc_main_window_timed_quit (gpointer dummy)
+{
+	if (gnc_file_save_in_progress())
+	  return TRUE;
+
+	gnc_shutdown (0);
+	return FALSE;
+}
+
 static void
 gnc_main_window_cmd_file_quit (GtkAction *action, GncMainWindow *window)
 {
 	QofSession *session;
+
+	if (gnc_file_save_in_progress()) {
+	  g_timeout_add(250, gnc_main_window_timed_quit, NULL);
+	  return;
+	}
+
 	session = qof_session_get_current_session();
 	if (qof_book_not_saved(qof_session_get_book(session))) {
 	  if (gnc_main_window_prompt_for_save(GTK_WIDGET(window))) {



More information about the gnucash-changes mailing list