diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-08-15 11:34:46 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-08-15 18:35:16 +0000 |
commit | 8b4572728d541e1039e4665dca8c6427db4a2132 (patch) | |
tree | 158a06951ac26f3173bd64429bb6957d50fb04f6 | |
parent | 1b467383de7aa2ea79b29fa552de35a4353ec921 (diff) |
Un-reference actions after adding them to an action group.
When created, they have a reference count of 1; when added to an action
group, the reference count is increased as a pointer is held by the
action group. Release the reference we got, as we're not holding onto
it.
Also, rename "menu_item" to "menu_action", to indicate that it's an action.
Change-Id: I54543dcc2e6c3b341a9f584fe1b6099a134771b3
Reviewed-on: https://code.wireshark.org/review/10049
Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r-- | ui/gtk/main_menubar.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index 476b67913b..a1f94578ef 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -5398,7 +5398,7 @@ ws_menubar_create_ui(ext_menu_t * menu, const char * xpath_parent, GtkActionGrou ext_menubar_t * item = NULL; GList * children = NULL; gchar * xpath, * submenu_xpath; - GtkAction * menu_item; + GtkAction * menu_action; gchar *action_name; gchar ** paths = NULL; @@ -5413,11 +5413,12 @@ ws_menubar_create_ui(ext_menu_t * menu, const char * xpath_parent, GtkActionGrou /* Create the action for the menu item and add it to the action group */ action_name = g_strconcat("/", menu->name, NULL); - menu_item = (GtkAction *)g_object_new ( GTK_TYPE_ACTION, + menu_action = (GtkAction *)g_object_new ( GTK_TYPE_ACTION, "name", action_name, "label", menu->label, NULL ); g_free(action_name); - gtk_action_group_add_action(action_group, menu_item); + gtk_action_group_add_action(action_group, menu_action); + g_object_unref(menu_action); children = menu->children; @@ -5436,13 +5437,14 @@ ws_menubar_create_ui(ext_menu_t * menu, const char * xpath_parent, GtkActionGrou else if ( item->type != EXT_MENUBAR_SEPARATOR ) { action_name = g_strconcat("/", item->name, NULL); - menu_item = (GtkAction*) g_object_new( GTK_TYPE_ACTION, + menu_action = (GtkAction*) g_object_new( GTK_TYPE_ACTION, "name", action_name, "label", item->label, "tooltip", item->tooltip, NULL); - g_signal_connect(menu_item, "activate", G_CALLBACK(ws_menubar_external_cb), item ); - gtk_action_group_add_action(action_group, menu_item); + g_signal_connect(menu_action, "activate", G_CALLBACK(ws_menubar_external_cb), item ); + gtk_action_group_add_action(action_group, menu_action); + g_object_unref(menu_action); g_free(action_name); /* Create the correct action path */ |