Skip to content

Commit

Permalink
Remove plugin preferences
Browse files Browse the repository at this point in the history
Make sure when a GncMainWindow closes that the preference callbacks
that were setup for the plugins are removed. At this point the actions
are not touched as it causes errors to be logged to the terminal.
  • Loading branch information
Bob-IT committed Aug 18, 2019
1 parent 93dd58c commit f043a82
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions gnucash/gnome-utils/gnc-main-window.c
Expand Up @@ -2747,6 +2747,7 @@ gnc_main_window_new (void)
active_windows = g_list_append (active_windows, window);
gnc_main_window_update_title(window);
window->window_quitting = FALSE;
window->just_plugin_prefs = FALSE;
#ifdef MAC_INTEGRATION
gnc_quartz_set_menu(window);
#else
Expand Down Expand Up @@ -3115,6 +3116,15 @@ gnc_main_window_close_page (GncPluginPage *page)
priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
if (priv->installed_pages == NULL)
{
GncPluginManager *manager = gnc_plugin_manager_get ();
GList *plugins = gnc_plugin_manager_get_plugins (manager);

/* remove only the preference callbacks from the window plugins */
window->just_plugin_prefs = TRUE;
g_list_foreach (plugins, gnc_main_window_remove_plugin, window);
window->just_plugin_prefs = FALSE;
g_list_free (plugins);

/* remove the preference callbacks from the main window */
gnc_main_window_remove_prefs (window);

Expand Down
1 change: 1 addition & 0 deletions gnucash/gnome-utils/gnc-main-window.h
Expand Up @@ -58,6 +58,7 @@ typedef struct GncMainWindow
GtkUIManager *ui_merge; /**< A pointer to the UI Manager data
structure for the whole window. */
gboolean window_quitting; /**< Set to TRUE when quitting from this window. */
gboolean just_plugin_prefs; /**< Just remove preferences only from plugins */
} GncMainWindow;

/** The class data structure for a main window object. */
Expand Down
3 changes: 2 additions & 1 deletion gnucash/gnome-utils/gnc-plugin-menu-additions.c
Expand Up @@ -474,7 +474,8 @@ gnc_plugin_menu_additions_remove_from_window (GncPlugin *plugin,
/* Have to remove our actions manually. Its only automatic if the
* actions name is installed into the plugin class. */
group = gnc_main_window_get_action_group(window, PLUGIN_ACTIONS_NAME);
if (group)

if (group && !window->just_plugin_prefs)
gtk_ui_manager_remove_action_group(window->ui_merge, group);

/* Note: This code does not clean up the per-callback data structures
Expand Down
2 changes: 1 addition & 1 deletion gnucash/gnome-utils/gnc-plugin.c
Expand Up @@ -201,7 +201,7 @@ gnc_plugin_remove_from_window (GncPlugin *plugin,
/*
* Update window to remove UI items
*/
if (klass->actions_name)
if (klass->actions_name && !window->just_plugin_prefs)
{
DEBUG ("%s: %d actions to unmerge",
klass->actions_name, (klass->n_actions + klass->n_toggle_actions));
Expand Down

0 comments on commit f043a82

Please sign in to comment.