mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-24 18:00:31 -06:00
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
This commit is contained in:
parent
ff10b1d314
commit
fa3043a631
@ -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)
|
||||
|
@ -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(" ");
|
||||
|
@ -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);
|
||||
|
@ -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(),
|
||||
|
Loading…
Reference in New Issue
Block a user