r15169 - gnucash/trunk/src/gnome-utils - Factor out some quiting code from gnc_main_window_delete_event() and
Chris Shoemaker
chris at cvs.gnucash.org
Sat Dec 2 19:56:02 EST 2006
Author: chris
Date: 2006-12-02 19:56:01 -0500 (Sat, 02 Dec 2006)
New Revision: 15169
Trac: http://svn.gnucash.org/trac/changeset/15169
Modified:
gnucash/trunk/src/gnome-utils/gnc-main-window.c
Log:
Factor out some quiting code from gnc_main_window_delete_event() and
gnc_main_window_cmd_file_quit(). The new implementation fixes two bugs -
one in each of the previous implementations.
The bug in the gnc_main_window_cmd_file_quit() code was a race condition
whereby one could quit the application without finishing pending changes in
pages. This would happen if the began a save, modified the page during the
save, and then triggered the File->Quit command before the save completed.
For the register page, this sequence was possible, even though most of the UI
controls are disabled during save.
The bug in the gnc_main_window_delete_event() code was that it didn't check
for an in-progress save before prompting the user to save a dirty book.
Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c 2006-12-02 22:13:13 UTC (rev 15168)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c 2006-12-03 00:56:01 UTC (rev 15169)
@@ -995,6 +995,25 @@
}
static gboolean
+gnc_main_window_quit(GncMainWindow *window)
+{
+ QofSession *session;
+ gboolean needs_save, do_shutdown;
+
+ session = gnc_get_current_session();
+ needs_save = qof_book_not_saved(qof_session_get_book(session)) &&
+ !gnc_file_save_in_progress();
+ do_shutdown = !needs_save ||
+ (needs_save && !gnc_main_window_prompt_for_save(GTK_WIDGET(window)));
+
+ if (do_shutdown) {
+ g_timeout_add(250, gnc_main_window_timed_quit, NULL);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static gboolean
gnc_main_window_delete_event (GtkWidget *window,
GdkEvent *event,
gpointer user_data)
@@ -1013,21 +1032,7 @@
if (g_list_length(active_windows) > 1)
return FALSE;
- session = gnc_get_current_session();
- if (qof_book_not_saved(qof_session_get_book(session))) {
- if (!gnc_main_window_prompt_for_save(GTK_WIDGET(window))) {
- /* Tell gnucash to shutdown cleanly */
- g_timeout_add(250, gnc_main_window_timed_quit, NULL);
- already_dead = TRUE;
- }
- /* Cancel the window deletion. It'll happen on the just queued shutdown. */
- return TRUE;
- }
-
- /* Tell gnucash to shutdown cleanly */
- g_timeout_add(250, gnc_main_window_timed_quit, NULL);
- already_dead = TRUE;
-
+ already_dead = gnc_main_window_quit(GNC_MAIN_WINDOW(window));
return TRUE;
}
@@ -2958,25 +2963,12 @@
static void
gnc_main_window_cmd_file_quit (GtkAction *action, GncMainWindow *window)
{
- QofSession *session;
+ QofSession *session;
- if (gnc_file_save_in_progress()) {
- g_timeout_add(250, gnc_main_window_timed_quit, NULL);
- return;
- }
+ if (!gnc_main_window_all_finish_pending())
+ return;
- if (!gnc_main_window_all_finish_pending())
- return;
-
- session = gnc_get_current_session();
- if (qof_book_not_saved(qof_session_get_book(session))) {
- if (gnc_main_window_prompt_for_save(GTK_WIDGET(window))) {
- /* User canceled */
- return;
- }
- }
-
- gnc_shutdown (0);
+ gnc_main_window_quit(window);
}
static void
More information about the gnucash-changes
mailing list