gnucash maint: Follow up to Bug 798098 fix
Robert Fewell
bobit at code.gnucash.org
Tue Feb 23 05:49:39 EST 2021
Updated via https://github.com/Gnucash/gnucash/commit/2e5c419c (commit)
from https://github.com/Gnucash/gnucash/commit/8441aa86 (commit)
commit 2e5c419c9e076273832ee6f870d4c520a53d561d
Author: Robert Fewell <14uBobIT at gmail.com>
Date: Sat Feb 13 11:37:20 2021 +0000
Follow up to Bug 798098 fix
If there are GncMainWindows that have no pages added and Gnucash is
quitted they are not destroyed. This fix checks for windows with no
pages and then does a gtk_widget_destroy on them.
diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c
index 7ed6b8dc5..a792e02bc 100644
--- a/gnucash/gnome-utils/gnc-main-window.c
+++ b/gnucash/gnome-utils/gnc-main-window.c
@@ -924,7 +924,8 @@ cleanup:
if (error)
g_error_free(error);
g_free(window_group);
- gtk_widget_show(GTK_WIDGET(window));
+ if (window)
+ gtk_widget_show (GTK_WIDGET(window));
}
void
@@ -1405,12 +1406,26 @@ gnc_main_window_quit(GncMainWindow *window)
}
if (do_shutdown)
{
- GList *w;
+ GList *w, *next;
- for (w = active_windows; w; w = g_list_next (w))
+ /* This is not a typical list iteration. There is a possability
+ * that the window maybe removed from the active_windows list so
+ * we have to cache the 'next' pointer before executing any code
+ * in the loop. */
+ for (w = active_windows; w; w = next)
{
- window = w->data;
- window->window_quitting = TRUE; // set window_quitting on all windows
+ GncMainWindowPrivate *priv;
+ GncMainWindow *wind = w->data;
+
+ next = g_list_next (w);
+
+ wind->window_quitting = TRUE; // set window_quitting on all windows
+
+ priv = GNC_MAIN_WINDOW_GET_PRIVATE(wind);
+
+ // if there are no pages destroy window
+ if (priv->installed_pages == NULL)
+ gtk_widget_destroy (GTK_WIDGET(wind));
}
/* remove the preference callbacks from the main window */
gnc_main_window_remove_prefs (window);
@@ -1522,6 +1537,10 @@ gnc_main_window_event_handler (QofInstance *entity, QofEventId event_type,
if (gnc_plugin_page_has_book (page, (QofBook *)entity))
gnc_main_window_close_page (page);
}
+
+ if (GTK_IS_WIDGET(window) && window->window_quitting)
+ gtk_widget_destroy (GTK_WIDGET(window));
+
LEAVE(" ");
}
@@ -3322,14 +3341,9 @@ gnc_main_window_close_page (GncPluginPage *page)
/* remove the preference callbacks from the main window */
gnc_main_window_remove_prefs (window);
-
- gtk_widget_destroy (GTK_WIDGET(window));
- window = NULL;
}
if (window && g_list_length (active_windows) > 1)
- {
gtk_widget_destroy (GTK_WIDGET(window));
- }
}
}
Summary of changes:
gnucash/gnome-utils/gnc-main-window.c | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
More information about the gnucash-changes
mailing list