Skip to content

Commit

Permalink
Follow up to Bug 798098 fix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Bob-IT committed Feb 23, 2021
1 parent 8441aa8 commit 2e5c419
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions gnucash/gnome-utils/gnc-main-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,8 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da
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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(" ");
}

Expand Down Expand Up @@ -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));
}
}
}

Expand Down

0 comments on commit 2e5c419

Please sign in to comment.