r15176 - gnucash/branches/2.0 - Factor out some quiting code from gnc_main_window_delete_event()
Derek Atkins
warlord at cvs.gnucash.org
Sat Dec 2 21:03:27 EST 2006
Author: warlord
Date: 2006-12-02 21:03:26 -0500 (Sat, 02 Dec 2006)
New Revision: 15176
Trac: http://svn.gnucash.org/trac/changeset/15176
Modified:
gnucash/branches/2.0/
gnucash/branches/2.0/ChangeLog
gnucash/branches/2.0/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.
Merge from r15169
Property changes on: gnucash/branches/2.0
___________________________________________________________________
Name: svk:merge
- 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/2.0:697
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/2.0:13663
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:13282
+ 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/branches/2.0:697
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/2.0:13664
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:13282
Modified: gnucash/branches/2.0/ChangeLog
===================================================================
--- gnucash/branches/2.0/ChangeLog 2006-12-03 02:03:10 UTC (rev 15175)
+++ gnucash/branches/2.0/ChangeLog 2006-12-03 02:03:26 UTC (rev 15176)
@@ -16,6 +16,24 @@
forked gzip process is finished, and it only knows how to keep
track of one child pid at a time.
+ --
+
+ 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.
+
2006-12-01 Andreas Köhler <andi5.py at gmx.net>
Save window size and position of the transfer dialog.
Modified: gnucash/branches/2.0/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/branches/2.0/src/gnome-utils/gnc-main-window.c 2006-12-03 02:03:10 UTC (rev 15175)
+++ gnucash/branches/2.0/src/gnome-utils/gnc-main-window.c 2006-12-03 02:03:26 UTC (rev 15176)
@@ -976,6 +976,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)
@@ -994,21 +1013,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;
}
@@ -2867,25 +2872,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