gnucash master: Multiple changes pushed

Robert Fewell bobit at code.gnucash.org
Sun Aug 18 08:39:52 EDT 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/f9dc1980 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/28b71bab (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f043a820 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/93dd58c2 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/61572515 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/8a448143 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e9bab3bf (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1344ea67 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/02f7a807 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/fc20aeb2 (commit)
	from  https://github.com/Gnucash/gnucash/commit/0e93e95c (commit)



commit f9dc19803168e69643af0c2abb2750aa587c79e5
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sun Jul 28 12:03:37 2019 +0100

    Destroy the registered preference hash table
    
    With all the registered preference callbacks being removed, the hash
    table can now be destroyed and log a message to that effect.

diff --git a/libgnucash/app-utils/gnc-gsettings.c b/libgnucash/app-utils/gnc-gsettings.c
index f93e8d335..d692f16fe 100644
--- a/libgnucash/app-utils/gnc-gsettings.c
+++ b/libgnucash/app-utils/gnc-gsettings.c
@@ -296,6 +296,13 @@ gnc_gsettings_remove_cb_by_id (const gchar *schema,
     // remove the handlerid from the registerered_handlers_hash
     g_hash_table_remove (registered_handlers_hash, GINT_TO_POINTER(handlerid));
 
+    // destroy hash table if size is 0
+    if (g_hash_table_size (registered_handlers_hash) == 0)
+    {
+        g_hash_table_destroy (registered_handlers_hash);
+        PINFO ("All registered preference callbacks removed");
+    }
+
     LEAVE ("Schema: %s, handlerid: %d, hashtable size: %d - removed for handler",
             schema, handlerid, g_hash_table_size (registered_handlers_hash));
 }

commit 28b71bab58b9438edab60abb6fb9675da0314db1
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sun Jul 28 12:03:00 2019 +0100

    Change the shutdown hook for the plugin manager
    
    When quitting with multiple windows, as the first window closes the
    plugin manager is shutdown and so the plugins for subsequent windows
    can not remove the preference callbacks that were setup so move the
    manager shutdown hook to HOOK_SHUTDOWN as opposed to HOOK_UI_SHUTDOWN.

diff --git a/gnucash/gnome-utils/gnc-plugin-manager.c b/gnucash/gnome-utils/gnc-plugin-manager.c
index 73fb9ebea..822fec2ba 100644
--- a/gnucash/gnome-utils/gnc-plugin-manager.c
+++ b/gnucash/gnome-utils/gnc-plugin-manager.c
@@ -66,7 +66,7 @@ gnc_plugin_manager_get (void)
     {
         singleton = g_object_new (GNC_TYPE_PLUGIN_MANAGER,
                                   NULL);
-        gnc_hook_add_dangler (HOOK_UI_SHUTDOWN,
+        gnc_hook_add_dangler (HOOK_SHUTDOWN,
                               gnc_plugin_manager_shutdown, NULL);
     }
 

commit f043a820f325e4c4cb386bd56aad73d09480ffbe
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sun Jul 28 12:02:22 2019 +0100

    Remove plugin preferences
    
    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.

diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c
index a0f364279..a96aff8d9 100644
--- a/gnucash/gnome-utils/gnc-main-window.c
+++ b/gnucash/gnome-utils/gnc-main-window.c
@@ -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
@@ -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);
 
diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h
index e599852e5..cea61e243 100644
--- a/gnucash/gnome-utils/gnc-main-window.h
+++ b/gnucash/gnome-utils/gnc-main-window.h
@@ -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. */
diff --git a/gnucash/gnome-utils/gnc-plugin-menu-additions.c b/gnucash/gnome-utils/gnc-plugin-menu-additions.c
index 2cc489824..090ccbbff 100644
--- a/gnucash/gnome-utils/gnc-plugin-menu-additions.c
+++ b/gnucash/gnome-utils/gnc-plugin-menu-additions.c
@@ -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
diff --git a/gnucash/gnome-utils/gnc-plugin.c b/gnucash/gnome-utils/gnc-plugin.c
index d84f359e4..77240c3f2 100644
--- a/gnucash/gnome-utils/gnc-plugin.c
+++ b/gnucash/gnome-utils/gnc-plugin.c
@@ -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));

commit 93dd58c2143874843574499747bb4929bbe0d3a4
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sun Jul 28 12:01:18 2019 +0100

    Restrict removing preference callbacks setup via g_once
    
    Only remove the register callbacks setup with 'g_once' to when quitting.

diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c
index f051389d1..a0f364279 100644
--- a/gnucash/gnome-utils/gnc-main-window.c
+++ b/gnucash/gnome-utils/gnc-main-window.c
@@ -1385,6 +1385,7 @@ gnc_main_window_quit(GncMainWindow *window)
     if (do_shutdown)
     {
         /* remove the preference callbacks from the main window */
+        window->window_quitting = TRUE;
         gnc_main_window_remove_prefs (window);
         g_timeout_add(250, gnc_main_window_timed_quit, NULL);
         return TRUE;
@@ -2654,7 +2655,7 @@ gnc_main_window_remove_prefs (GncMainWindow *window)
                                  window);
 
     // remove the registered negative color preference callback.
-    if (gnc_prefs_get_reg_negative_color_pref_id() > 0)
+    if (gnc_prefs_get_reg_negative_color_pref_id() > 0 && window->window_quitting)
     {
         gnc_prefs_remove_cb_by_id (GNC_PREFS_GROUP_GENERAL,
                                    gnc_prefs_get_reg_negative_color_pref_id());
@@ -2662,7 +2663,7 @@ gnc_main_window_remove_prefs (GncMainWindow *window)
     }
 
     // remove the registered auto_raise_lists preference callback.
-    if (gnc_prefs_get_reg_auto_raise_lists_id() > 0)
+    if (gnc_prefs_get_reg_auto_raise_lists_id() > 0 && window->window_quitting)
     {
         gnc_prefs_remove_cb_by_id (GNC_PREFS_GROUP_GENERAL_REGISTER,
                                    gnc_prefs_get_reg_auto_raise_lists_id());
@@ -2745,6 +2746,7 @@ gnc_main_window_new (void)
     }
     active_windows = g_list_append (active_windows, window);
     gnc_main_window_update_title(window);
+    window->window_quitting = FALSE;
 #ifdef MAC_INTEGRATION
     gnc_quartz_set_menu(window);
 #else
diff --git a/gnucash/gnome-utils/gnc-main-window.h b/gnucash/gnome-utils/gnc-main-window.h
index cec14f13f..e599852e5 100644
--- a/gnucash/gnome-utils/gnc-main-window.h
+++ b/gnucash/gnome-utils/gnc-main-window.h
@@ -56,7 +56,8 @@ typedef struct GncMainWindow
 {
     GtkWindow gtk_window;	/**< The parent object for a main window. */
     GtkUIManager *ui_merge; /**< A pointer to the UI Manager data
-				   structure for the whole window. */
+                                 structure for the whole window. */
+    gboolean window_quitting; /**< Set to TRUE when quitting from this window. */
 } GncMainWindow;
 
 /** The class data structure for a main window object. */

commit 6157251573c0773bd39bad6f342c51eccc92388f
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sun Jul 28 11:58:24 2019 +0100

    Remove registered pref callbacks for the register
    
    A couple of preference callbacks are setup to track the
    'negative_color_preference' and 'auto_raise_lists' which are setup with
    a call to 'g_once'. To be able to remove these, the the preference id
    is saved so that they can be used in gnc_main_window_remove_prefs to
    remove the callback.

diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c
index 8e12d12f5..f051389d1 100644
--- a/gnucash/gnome-utils/gnc-main-window.c
+++ b/gnucash/gnome-utils/gnc-main-window.c
@@ -2652,6 +2652,22 @@ gnc_main_window_remove_prefs (GncMainWindow *window)
                                  GNC_PREF_TAB_POSITION_RIGHT,
                                  gnc_main_window_update_tab_position,
                                  window);
+
+    // remove the registered negative color preference callback.
+    if (gnc_prefs_get_reg_negative_color_pref_id() > 0)
+    {
+        gnc_prefs_remove_cb_by_id (GNC_PREFS_GROUP_GENERAL,
+                                   gnc_prefs_get_reg_negative_color_pref_id());
+        gnc_prefs_set_reg_negative_color_pref_id (0);
+    }
+
+    // remove the registered auto_raise_lists preference callback.
+    if (gnc_prefs_get_reg_auto_raise_lists_id() > 0)
+    {
+        gnc_prefs_remove_cb_by_id (GNC_PREFS_GROUP_GENERAL_REGISTER,
+                                   gnc_prefs_get_reg_auto_raise_lists_id());
+        gnc_prefs_set_reg_auto_raise_lists_id (0);
+    }
 }
 
 
diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c
index 1e45fbc03..1741aed8c 100644
--- a/gnucash/register/ledger-core/split-register-model.c
+++ b/gnucash/register/ledger-core/split-register-model.c
@@ -2459,9 +2459,13 @@ gnc_split_register_colorize_negative (gpointer gsettings, gchar *key, gpointer u
 static gpointer
 gnc_split_register_model_add_hooks (gpointer unused)
 {
-    gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED,
-                          gnc_split_register_colorize_negative,
-                          NULL);
+    gulong id = gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
+                                       GNC_PREF_NEGATIVE_IN_RED,
+                                       gnc_split_register_colorize_negative,
+                                       NULL);
+
+    gnc_prefs_set_reg_negative_color_pref_id (id);
+
     /* Get the initial value */
     use_red_for_negative = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL,
                                               GNC_PREF_NEGATIVE_IN_RED);
diff --git a/gnucash/register/register-gnome/combocell-gnome.c b/gnucash/register/register-gnome/combocell-gnome.c
index fc8120d8f..0905b6382 100644
--- a/gnucash/register/register-gnome/combocell-gnome.c
+++ b/gnucash/register/register-gnome/combocell-gnome.c
@@ -99,13 +99,16 @@ gnc_combo_cell_set_autopop (gpointer prefs, gchar *pref, gpointer user_data)
 static gpointer
 gnc_combo_cell_autopop_init (gpointer unused)
 {
+    gulong id;
     auto_pop_combos = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL_REGISTER,
                                           GNC_PREF_AUTO_RAISE_LISTS);
 
-    gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER,
-                           GNC_PREF_AUTO_RAISE_LISTS,
-                           gnc_combo_cell_set_autopop,
-                           NULL);
+    id = gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER,
+                                GNC_PREF_AUTO_RAISE_LISTS,
+                                gnc_combo_cell_set_autopop,
+                                NULL);
+
+    gnc_prefs_set_reg_auto_raise_lists_id (id);
     return NULL;
 }
 
diff --git a/libgnucash/core-utils/gnc-prefs.c b/libgnucash/core-utils/gnc-prefs.c
index d59e91f63..c17b95714 100644
--- a/libgnucash/core-utils/gnc-prefs.c
+++ b/libgnucash/core-utils/gnc-prefs.c
@@ -35,6 +35,12 @@ static gboolean use_compression   = TRUE; // This is also the default in the pre
 static gint file_retention_policy = 1;    // 1 = "days", the default in the prefs backend
 static gint file_retention_days   = 30;   // This is also the default in the prefs backend
 
+
+/* Global variables used to remove the preference registered callbacks
+ * that were setup via a g_once. */
+static gulong reg_auto_raise_lists_id;
+static gulong reg_negative_color_pref_id;
+
 PrefsBackend *prefsbackend = NULL;
 
 const gchar *
@@ -379,3 +385,24 @@ void gnc_prefs_unblock_all (void)
     if (prefsbackend && prefsbackend->unblock_all)
         (prefsbackend->unblock_all) ();
 }
+
+gulong gnc_prefs_get_reg_auto_raise_lists_id (void)
+{
+    return reg_auto_raise_lists_id;
+}
+
+void gnc_prefs_set_reg_auto_raise_lists_id (gulong id)
+{
+    reg_auto_raise_lists_id = id;
+}
+
+gulong gnc_prefs_get_reg_negative_color_pref_id (void)
+{
+    return reg_negative_color_pref_id;
+}
+
+void gnc_prefs_set_reg_negative_color_pref_id (gulong id)
+{
+    reg_negative_color_pref_id = id;
+}
+
diff --git a/libgnucash/core-utils/gnc-prefs.h b/libgnucash/core-utils/gnc-prefs.h
index c665a2621..b18d1e079 100644
--- a/libgnucash/core-utils/gnc-prefs.h
+++ b/libgnucash/core-utils/gnc-prefs.h
@@ -553,6 +553,16 @@ void gnc_prefs_reset (const gchar *group,
  */
 void gnc_prefs_reset_group (const gchar *group);
 
+/** Get and Set registered preference id for register auto_raise_lists
+ */
+gulong gnc_prefs_get_reg_auto_raise_lists_id (void);
+void gnc_prefs_set_reg_auto_raise_lists_id (gulong id);
+
+/** Get and Set registered preference id for register negative_color_pref
+ */
+gulong gnc_prefs_get_reg_negative_color_pref_id (void);
+void gnc_prefs_set_reg_negative_color_pref_id (gulong id);
+
 /** @} */
 
 

commit 8a44814378c7641abab93a14722e31d0bc030961
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sun Jul 28 11:46:32 2019 +0100

    Remove the registered preference callbacks in
     gnc-main-window.c
    
    Add a function to remove all the registered preference callbacks that
    were setup in gnc-main-window.c and call it from three places. One is
    gnc_mian_window_quit which is used when the application quits and
    gnc_main_window_close_page, gnc_main_window_destroy which is used when
    separate windows are used for pages like the register and they are
    closed.

diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c
index fc0fea38f..8e12d12f5 100644
--- a/gnucash/gnome-utils/gnc-main-window.c
+++ b/gnucash/gnome-utils/gnc-main-window.c
@@ -175,6 +175,8 @@ static void gnc_main_window_cmd_help_about (GtkAction *action, GncMainWindow *wi
 static void do_popup_menu(GncPluginPage *page, GdkEventButton *event);
 static GtkWidget *gnc_main_window_get_statusbar (GncWindow *window_in);
 static void statusbar_notification_lastmodified(void);
+static void gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_data);
+static void gnc_main_window_remove_prefs (GncMainWindow *window);
 
 #ifdef MAC_INTEGRATION
 static void gnc_quartz_shutdown(GtkosxApplication *theApp, gpointer data);
@@ -1382,6 +1384,8 @@ gnc_main_window_quit(GncMainWindow *window)
     }
     if (do_shutdown)
     {
+        /* remove the preference callbacks from the main window */
+        gnc_main_window_remove_prefs (window);
         g_timeout_add(250, gnc_main_window_timed_quit, NULL);
         return TRUE;
     }
@@ -2610,6 +2614,47 @@ gnc_main_window_finalize (GObject *object)
 }
 
 
+static void
+gnc_main_window_remove_prefs (GncMainWindow *window)
+{
+    // remove the registered preference callbacks setup in this file.
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_TAB_COLOR,
+                                 gnc_main_window_update_tab_color,
+                                 window);
+
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_SHOW_CLOSE_BUTTON,
+                                 gnc_main_window_update_tab_close,
+                                 NULL);
+
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_TAB_WIDTH,
+                                 gnc_main_window_update_tab_width,
+                                 NULL);
+
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_TAB_POSITION_TOP,
+                                 gnc_main_window_update_tab_position,
+                                 window);
+
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_TAB_POSITION_BOTTOM,
+                                 gnc_main_window_update_tab_position,
+                                 window);
+
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_TAB_POSITION_LEFT,
+                                 gnc_main_window_update_tab_position,
+                                 window);
+
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_TAB_POSITION_RIGHT,
+                                 gnc_main_window_update_tab_position,
+                                 window);
+}
+
+
 static void
 gnc_main_window_destroy (GtkWidget *widget)
 {
@@ -2640,10 +2685,8 @@ gnc_main_window_destroy (GtkWidget *widget)
         /* Update the "Windows" menu in all other windows */
         gnc_main_window_update_all_menu_items();
 #endif
-        gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
-                                     GNC_PREF_TAB_COLOR,
-                                     gnc_main_window_update_tab_color,
-                                     window);
+        /* remove the preference callbacks from the main window */
+        gnc_main_window_remove_prefs (window);
 
         qof_event_unregister_handler(priv->event_handler_id);
         priv->event_handler_id = 0;
@@ -3054,6 +3097,9 @@ gnc_main_window_close_page (GncPluginPage *page)
     priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
     if (priv->installed_pages == NULL)
     {
+        /* remove the preference callbacks from the main window */
+        gnc_main_window_remove_prefs (window);
+
         if (g_list_length(active_windows) > 1)
         {
             gtk_widget_destroy(GTK_WIDGET(window));

commit e9bab3bf98fc8942e9ac62495d2fb13bc59a612e
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Jul 27 17:49:29 2019 +0100

    Add the removal of preference call backs to
     gnc_gui_destroy
    
    Add the removal of preferences setup in gnc-gnome-utils and also call
    the other two functions to remove further preference call backs.

diff --git a/gnucash/gnome-utils/gnc-gnome-utils.c b/gnucash/gnome-utils/gnc-gnome-utils.c
index 87631690f..ef389cf66 100644
--- a/gnucash/gnome-utils/gnc-gnome-utils.c
+++ b/gnucash/gnome-utils/gnc-gnome-utils.c
@@ -748,6 +748,31 @@ gnc_gui_destroy (void)
     if (!gnome_is_initialized)
         return;
 
+    if (gnc_prefs_is_set_up())
+    {
+        gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                     GNC_PREF_DATE_FORMAT,
+                                     gnc_configure_date_format,
+                                     NULL);
+        gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                     GNC_PREF_DATE_COMPL_THISYEAR,
+                                     gnc_configure_date_completion,
+                                     NULL);
+        gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                     GNC_PREF_DATE_COMPL_SLIDING,
+                                     gnc_configure_date_completion,
+                                     NULL);
+        gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                     GNC_PREF_DATE_BACKMONTHS,
+                                     gnc_configure_date_completion,
+                                     NULL);
+        gnc_prefs_remove_group_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                           gnc_gui_refresh_all,
+                                           NULL);
+
+        gnc_ui_util_remove_registered_prefs ();
+        gnc_prefs_remove_registered ();
+    }
     gnc_extensions_shutdown ();
 }
 

commit 1344ea67e7af93e78bcd7eb38eadc4313633c303
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Jul 27 17:48:42 2019 +0100

    Create a function to remove the registered preference
     call backs setup in gnc-prefs-utils.c

diff --git a/libgnucash/app-utils/gnc-prefs-utils.c b/libgnucash/app-utils/gnc-prefs-utils.c
index 0ea96b5ba..c74405b70 100644
--- a/libgnucash/app-utils/gnc-prefs-utils.c
+++ b/libgnucash/app-utils/gnc-prefs-utils.c
@@ -124,3 +124,19 @@ void gnc_prefs_init (void)
                            file_compression_changed_cb, NULL);
 
 }
+
+void
+gnc_prefs_remove_registered (void)
+{
+    // remove the registered pref call backs above
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_DAYS,
+                           file_retain_changed_cb, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_TYPE_NEVER,
+                           file_retain_type_changed_cb, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_TYPE_DAYS,
+                           file_retain_type_changed_cb, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, GNC_PREF_RETAIN_TYPE_FOREVER,
+                           file_retain_type_changed_cb, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL, GNC_PREF_FILE_COMPRESSION,
+                           file_compression_changed_cb, NULL);
+}
diff --git a/libgnucash/app-utils/gnc-prefs-utils.h b/libgnucash/app-utils/gnc-prefs-utils.h
index 49f7ad03b..1eaf935eb 100644
--- a/libgnucash/app-utils/gnc-prefs-utils.h
+++ b/libgnucash/app-utils/gnc-prefs-utils.h
@@ -47,6 +47,11 @@
  */
 void gnc_prefs_init (void);
 
+/** This function is called to remove the registered preference
+ *  call backs setup in this file
+ */
+void gnc_prefs_remove_registered (void);
+
 #endif /* GNC_PREFS_UTILS_H_ */
 /** @} */
 /** @} */

commit 02f7a807de5d8f77d018f7eb6f32ab207de81c6c
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Jul 27 17:48:12 2019 +0100

    Create a function to remove the registered preference
     call backs setup in gnc-ui-util.c

diff --git a/libgnucash/app-utils/gnc-ui-util.c b/libgnucash/app-utils/gnc-ui-util.c
index ac13a58d7..0c6213e5f 100644
--- a/libgnucash/app-utils/gnc-ui-util.c
+++ b/libgnucash/app-utils/gnc-ui-util.c
@@ -1511,7 +1511,7 @@ gnc_default_price_print_info (const gnc_commodity *curr)
     info.use_symbol = 0;
     info.use_locale = 1;
     info.monetary = 1;
-    
+
     info.force_fit = force;
     info.round = force;
     return info;
@@ -2675,3 +2675,45 @@ gnc_ui_util_init (void)
                           gnc_set_auto_decimal_places, NULL);
 
 }
+
+void
+gnc_ui_util_remove_registered_prefs (void)
+{
+    // remove the registered pref call backs above
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_ACCOUNT_SEPARATOR,
+                                 gnc_configure_account_separator, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_REVERSED_ACCTS_NONE,
+                                 gnc_configure_reverse_balance, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_REVERSED_ACCTS_CREDIT,
+                                 gnc_configure_reverse_balance, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_REVERSED_ACCTS_INC_EXP,
+                                 gnc_configure_reverse_balance, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_CURRENCY_CHOICE_LOCALE,
+                                 gnc_currency_changed_cb, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_CURRENCY_CHOICE_OTHER,
+                                 gnc_currency_changed_cb, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_CURRENCY_OTHER,
+                                 gnc_currency_changed_cb, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL_REPORT,
+                                 GNC_PREF_CURRENCY_CHOICE_LOCALE,
+                                 gnc_currency_changed_cb, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL_REPORT,
+                                 GNC_PREF_CURRENCY_CHOICE_OTHER,
+                                 gnc_currency_changed_cb, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL_REPORT,
+                                 GNC_PREF_CURRENCY_OTHER,
+                                 gnc_currency_changed_cb, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_AUTO_DECIMAL_POINT,
+                                 gnc_set_auto_decimal_enabled, NULL);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_AUTO_DECIMAL_PLACES,
+                                 gnc_set_auto_decimal_places, NULL);
+}
diff --git a/libgnucash/app-utils/gnc-ui-util.h b/libgnucash/app-utils/gnc-ui-util.h
index 4601f3b8b..dd890b939 100644
--- a/libgnucash/app-utils/gnc-ui-util.h
+++ b/libgnucash/app-utils/gnc-ui-util.h
@@ -355,6 +355,10 @@ xaccParseAmountExtended (const char * in_str, gboolean monetary,
 
 void gnc_ui_util_init (void);
 
+/* Remove callback preferences **************************************/
+
+void gnc_ui_util_remove_registered_prefs (void);
+
 #endif
 /** @} */
 /** @} */

commit fc20aeb2df11974c5e2eacbf2ad21f0b0314f244
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Sat Jul 27 17:47:43 2019 +0100

    Wrong group specified for quickfill remove pref.

diff --git a/gnucash/gnome-utils/account-quickfill.c b/gnucash/gnome-utils/account-quickfill.c
index 729ce39cc..35819e8c8 100644
--- a/gnucash/gnome-utils/account-quickfill.c
+++ b/gnucash/gnome-utils/account-quickfill.c
@@ -65,7 +65,7 @@ static void
 shared_quickfill_destroy (QofBook *book, gpointer key, gpointer user_data)
 {
     QFB *qfb = user_data;
-    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL_REGISTER,
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
                                  GNC_PREF_ACCOUNT_SEPARATOR,
                                  shared_quickfill_pref_changed,
                                  qfb);



Summary of changes:
 gnucash/gnome-utils/account-quickfill.c            |  2 +-
 gnucash/gnome-utils/gnc-gnome-utils.c              | 25 +++++++
 gnucash/gnome-utils/gnc-main-window.c              | 82 ++++++++++++++++++++--
 gnucash/gnome-utils/gnc-main-window.h              |  4 +-
 gnucash/gnome-utils/gnc-plugin-manager.c           |  2 +-
 gnucash/gnome-utils/gnc-plugin-menu-additions.c    |  3 +-
 gnucash/gnome-utils/gnc-plugin.c                   |  2 +-
 .../register/ledger-core/split-register-model.c    | 10 ++-
 gnucash/register/register-gnome/combocell-gnome.c  | 11 +--
 libgnucash/app-utils/gnc-gsettings.c               |  7 ++
 libgnucash/app-utils/gnc-prefs-utils.c             | 16 +++++
 libgnucash/app-utils/gnc-prefs-utils.h             |  5 ++
 libgnucash/app-utils/gnc-ui-util.c                 | 44 +++++++++++-
 libgnucash/app-utils/gnc-ui-util.h                 |  4 ++
 libgnucash/core-utils/gnc-prefs.c                  | 27 +++++++
 libgnucash/core-utils/gnc-prefs.h                  | 10 +++
 16 files changed, 237 insertions(+), 17 deletions(-)



More information about the gnucash-changes mailing list