gnucash stable: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Mon Jun 26 20:56:20 EDT 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/fa3043a6 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ff10b1d3 (commit)
	from  https://github.com/Gnucash/gnucash/commit/aba64c97 (commit)



commit fa3043a631a30b10c445e575f009e9e652ac8fa6
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jun 26 21:26:44 2023 +0800

    g_menu_item_new must be g_object_unreffed
    
    Although gnome API usually insertions usually take ownership of the child
    element, in this case the GMenuItem attributes are copied into the
    GMenu.
    
    From https://docs.gtk.org/gio/method.Menu.insert_item.html --
    
    * Description
    
    Inserts item into menu.
    
    The “insertion” is actually done by copying all of the attribute and
    link values of item and using them to form a new item within menu. As
    such, item itself is not really inserted, but rather, a menu item that
    is exactly the same as the one presently described by item.
    
    This means that item is essentially useless after the insertion
    occurs. Any changes you make to it are ignored unless it is inserted
    again (at which point its updated values will be copied).
    
    You should probably just free item once you’re done.
    
    There are many convenience functions to take care of common cases. See
    g_menu_insert(), g_menu_insert_section() and g_menu_insert_submenu()
    as well as “prepend” and “append” variants of each of these functions.
    
    Available since: 2.32

diff --git a/gnucash/gnome-utils/gnc-gtk-utils.c b/gnucash/gnome-utils/gnc-gtk-utils.c
index a023cd4b7f..c3c8fad1e8 100644
--- a/gnucash/gnome-utils/gnc-gtk-utils.c
+++ b/gnucash/gnome-utils/gnc-gtk-utils.c
@@ -907,6 +907,7 @@ gnc_menubar_model_update_item (GMenuModel *menu_model, const gchar *action_name,
 
             g_menu_remove (G_MENU(gsm->model), gsm->index);
             g_menu_insert_item (G_MENU(gsm->model), gsm->index, item);
+            g_object_unref (item);
             found = TRUE;
         }
         if (old_target)
diff --git a/gnucash/gnome-utils/gnc-main-window.cpp b/gnucash/gnome-utils/gnc-main-window.cpp
index e5b5f0929a..5dd830edf8 100644
--- a/gnucash/gnome-utils/gnc-main-window.cpp
+++ b/gnucash/gnome-utils/gnc-main-window.cpp
@@ -1820,6 +1820,7 @@ gnc_main_window_update_one_menu_action (GncMainWindow *window,
     if (pos < g_menu_model_get_n_items (gsm->model))
         g_menu_remove (G_MENU(gsm->model), pos);
     g_menu_insert_item (G_MENU(gsm->model), pos, item);
+    g_object_unref (item);
 
     g_free (gsm);
     LEAVE(" ");
diff --git a/gnucash/gnome-utils/gnc-plugin-file-history.c b/gnucash/gnome-utils/gnc-plugin-file-history.c
index 45174ba0bb..6b2c435af0 100644
--- a/gnucash/gnome-utils/gnc-plugin-file-history.c
+++ b/gnucash/gnome-utils/gnc-plugin-file-history.c
@@ -459,6 +459,7 @@ gnc_history_update_action (GncMainWindow *window,
         g_free (full_action_name);
         g_free (label_name);
         g_free (tooltip);
+        g_object_unref (item);
     }
     g_free (gsm);
     g_free (action_name);
diff --git a/gnucash/gnome-utils/gnc-plugin-menu-additions.c b/gnucash/gnome-utils/gnc-plugin-menu-additions.c
index 98ef68cb9b..69051b8630 100644
--- a/gnucash/gnome-utils/gnc-plugin-menu-additions.c
+++ b/gnucash/gnome-utils/gnc-plugin-menu-additions.c
@@ -481,7 +481,7 @@ gnc_plugin_menu_additions_add_to_window (GncPlugin *plugin,
         menu_plugin->item_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 
     per_window.item_hash = menu_plugin->item_hash;
-    per_window.build_menu_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+    per_window.build_menu_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
     per_window.report_menu = g_menu_new ();
 
     menu_list = g_slist_sort (gnc_extensions_get_menu_list(),

commit ff10b1d3149c14a222a0e26304a8d18e56e1b1f3
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jun 26 21:49:32 2023 +0800

    g_menu_model_iterate_item_attributes must be g_object_unreffed

diff --git a/gnucash/gnome-utils/gnc-gtk-utils.c b/gnucash/gnome-utils/gnc-gtk-utils.c
index 7e01b1a85e..a023cd4b7f 100644
--- a/gnucash/gnome-utils/gnc-gtk-utils.c
+++ b/gnucash/gnome-utils/gnc-gtk-utils.c
@@ -863,6 +863,7 @@ gnc_menubar_model_update_item (GMenuModel *menu_model, const gchar *action_name,
 
             g_variant_unref (value);
         }
+        g_object_unref (iter);
 
         if (!label && !gsm->search_action_label)
         {



Summary of changes:
 gnucash/gnome-utils/gnc-gtk-utils.c             | 2 ++
 gnucash/gnome-utils/gnc-main-window.cpp         | 1 +
 gnucash/gnome-utils/gnc-plugin-file-history.c   | 1 +
 gnucash/gnome-utils/gnc-plugin-menu-additions.c | 2 +-
 4 files changed, 5 insertions(+), 1 deletion(-)



More information about the gnucash-changes mailing list