forked from AuroraMiddleware/gtk
Add some refcount debugging.
2004-07-20 Matthias Clasen <mclasen@redhat.com> * tests/testactions.c (main): * tests/testmerge.c (main): Add some refcount debugging. * gtk/gtkuimanager.c (update_node, free_node): Ref an sink all proxies, so that we can properly clean up floating proxies which the app didn't adopt. (#147926, Tommi Komulainen)
This commit is contained in:
parent
9aeba99da0
commit
82877f9ee9
@ -1,3 +1,12 @@
|
||||
2004-07-20 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/testactions.c (main):
|
||||
* tests/testmerge.c (main): Add some refcount debugging.
|
||||
|
||||
* gtk/gtkuimanager.c (update_node, free_node): Ref an sink
|
||||
all proxies, so that we can properly clean up floating proxies
|
||||
which the app didn't adopt. (#147926, Tommi Komulainen)
|
||||
|
||||
2004-07-20 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Allow custom initialization of cell editables. (#147221)
|
||||
|
@ -1,3 +1,12 @@
|
||||
2004-07-20 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/testactions.c (main):
|
||||
* tests/testmerge.c (main): Add some refcount debugging.
|
||||
|
||||
* gtk/gtkuimanager.c (update_node, free_node): Ref an sink
|
||||
all proxies, so that we can properly clean up floating proxies
|
||||
which the app didn't adopt. (#147926, Tommi Komulainen)
|
||||
|
||||
2004-07-20 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Allow custom initialization of cell editables. (#147221)
|
||||
|
@ -1,3 +1,12 @@
|
||||
2004-07-20 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/testactions.c (main):
|
||||
* tests/testmerge.c (main): Add some refcount debugging.
|
||||
|
||||
* gtk/gtkuimanager.c (update_node, free_node): Ref an sink
|
||||
all proxies, so that we can properly clean up floating proxies
|
||||
which the app didn't adopt. (#147926, Tommi Komulainen)
|
||||
|
||||
2004-07-20 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Allow custom initialization of cell editables. (#147221)
|
||||
|
@ -1,3 +1,12 @@
|
||||
2004-07-20 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/testactions.c (main):
|
||||
* tests/testmerge.c (main): Add some refcount debugging.
|
||||
|
||||
* gtk/gtkuimanager.c (update_node, free_node): Ref an sink
|
||||
all proxies, so that we can properly clean up floating proxies
|
||||
which the app didn't adopt. (#147926, Tommi Komulainen)
|
||||
|
||||
2004-07-20 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Allow custom initialization of cell editables. (#147221)
|
||||
|
@ -954,6 +954,10 @@ free_node (GNode *node)
|
||||
|
||||
if (info->action)
|
||||
g_object_unref (info->action);
|
||||
if (info->proxy)
|
||||
g_object_unref (info->proxy);
|
||||
if (info->extra)
|
||||
g_object_unref (info->extra);
|
||||
g_free (info->name);
|
||||
g_chunk_free (info, merge_node_chunk);
|
||||
|
||||
@ -2124,6 +2128,8 @@ update_node (GtkUIManager *self,
|
||||
if (info->proxy == NULL)
|
||||
{
|
||||
info->proxy = gtk_menu_bar_new ();
|
||||
g_object_ref (info->proxy);
|
||||
gtk_object_sink (info->proxy);
|
||||
gtk_widget_set_name (info->proxy, info->name);
|
||||
gtk_widget_show (info->proxy);
|
||||
g_signal_emit (self, ui_manager_signals[ADD_WIDGET], 0, info->proxy);
|
||||
@ -2131,7 +2137,11 @@ update_node (GtkUIManager *self,
|
||||
break;
|
||||
case NODE_TYPE_POPUP:
|
||||
if (info->proxy == NULL)
|
||||
info->proxy = gtk_menu_new ();
|
||||
{
|
||||
info->proxy = gtk_menu_new ();
|
||||
g_object_ref (info->proxy);
|
||||
gtk_object_sink (info->proxy);
|
||||
}
|
||||
gtk_widget_set_name (info->proxy, info->name);
|
||||
break;
|
||||
case NODE_TYPE_MENU:
|
||||
@ -2152,6 +2162,7 @@ update_node (GtkUIManager *self,
|
||||
gtk_action_disconnect_proxy (info->action, info->proxy);
|
||||
gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
|
||||
info->proxy);
|
||||
g_object_unref (info->proxy);
|
||||
info->proxy = NULL;
|
||||
}
|
||||
/* create proxy if needed ... */
|
||||
@ -2166,6 +2177,8 @@ update_node (GtkUIManager *self,
|
||||
GtkWidget *filler;
|
||||
|
||||
info->proxy = gtk_action_create_menu_item (action);
|
||||
g_object_ref (info->proxy);
|
||||
gtk_object_sink (info->proxy);
|
||||
menu = gtk_menu_new ();
|
||||
gtk_widget_set_name (info->proxy, info->name);
|
||||
gtk_widget_set_name (menu, info->name);
|
||||
@ -2210,6 +2223,8 @@ update_node (GtkUIManager *self,
|
||||
if (info->proxy == NULL)
|
||||
{
|
||||
info->proxy = gtk_toolbar_new ();
|
||||
g_object_ref (info->proxy);
|
||||
gtk_object_sink (info->proxy);
|
||||
gtk_widget_set_name (info->proxy, info->name);
|
||||
gtk_widget_show (info->proxy);
|
||||
g_signal_emit (self, ui_manager_signals[ADD_WIDGET], 0, info->proxy);
|
||||
@ -2224,12 +2239,14 @@ update_node (GtkUIManager *self,
|
||||
{
|
||||
gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
|
||||
info->proxy);
|
||||
g_object_unref (info->proxy);
|
||||
info->proxy = NULL;
|
||||
}
|
||||
if (info->extra)
|
||||
{
|
||||
gtk_container_remove (GTK_CONTAINER (info->extra->parent),
|
||||
info->extra);
|
||||
g_object_unref (info->extra);
|
||||
info->extra = NULL;
|
||||
}
|
||||
}
|
||||
@ -2241,6 +2258,8 @@ update_node (GtkUIManager *self,
|
||||
if (find_menu_position (node, &menushell, &pos))
|
||||
{
|
||||
info->proxy = gtk_separator_menu_item_new ();
|
||||
g_object_ref (info->proxy);
|
||||
gtk_object_sink (info->proxy);
|
||||
g_object_set_data (G_OBJECT (info->proxy),
|
||||
"gtk-separator-mode",
|
||||
GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
|
||||
@ -2249,6 +2268,8 @@ update_node (GtkUIManager *self,
|
||||
NODE_INFO (node)->proxy, pos);
|
||||
|
||||
info->extra = gtk_separator_menu_item_new ();
|
||||
g_object_ref (info->extra);
|
||||
gtk_object_sink (info->extra);
|
||||
g_object_set_data (G_OBJECT (info->extra),
|
||||
"gtk-separator-mode",
|
||||
GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
|
||||
@ -2267,12 +2288,14 @@ update_node (GtkUIManager *self,
|
||||
{
|
||||
gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
|
||||
info->proxy);
|
||||
g_object_unref (info->proxy);
|
||||
info->proxy = NULL;
|
||||
}
|
||||
if (info->extra)
|
||||
{
|
||||
gtk_container_remove (GTK_CONTAINER (info->extra->parent),
|
||||
info->extra);
|
||||
g_object_unref (info->extra);
|
||||
info->extra = NULL;
|
||||
}
|
||||
}
|
||||
@ -2288,6 +2311,8 @@ update_node (GtkUIManager *self,
|
||||
item = gtk_separator_tool_item_new ();
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, pos);
|
||||
info->proxy = GTK_WIDGET (item);
|
||||
g_object_ref (info->proxy);
|
||||
gtk_object_sink (info->proxy);
|
||||
g_object_set_data (G_OBJECT (info->proxy),
|
||||
"gtk-separator-mode",
|
||||
GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
|
||||
@ -2296,6 +2321,8 @@ update_node (GtkUIManager *self,
|
||||
item = gtk_separator_tool_item_new ();
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, pos+1);
|
||||
info->extra = GTK_WIDGET (item);
|
||||
g_object_ref (info->extra);
|
||||
gtk_object_sink (info->extra);
|
||||
g_object_set_data (G_OBJECT (info->extra),
|
||||
"gtk-separator-mode",
|
||||
GINT_TO_POINTER (SEPARATOR_MODE_HIDDEN));
|
||||
@ -2314,6 +2341,7 @@ update_node (GtkUIManager *self,
|
||||
gtk_action_disconnect_proxy (info->action, info->proxy);
|
||||
gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
|
||||
info->proxy);
|
||||
g_object_unref (info->proxy);
|
||||
info->proxy = NULL;
|
||||
}
|
||||
/* create proxy if needed ... */
|
||||
@ -2325,6 +2353,8 @@ update_node (GtkUIManager *self,
|
||||
if (find_menu_position (node, &menushell, &pos))
|
||||
{
|
||||
info->proxy = gtk_action_create_menu_item (action);
|
||||
g_object_ref (info->proxy);
|
||||
gtk_object_sink (info->proxy);
|
||||
gtk_widget_set_name (info->proxy, info->name);
|
||||
|
||||
gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
|
||||
@ -2353,8 +2383,8 @@ update_node (GtkUIManager *self,
|
||||
break;
|
||||
case NODE_TYPE_TOOLITEM:
|
||||
/* remove the proxy if it is of the wrong type ... */
|
||||
if (info->proxy && G_OBJECT_TYPE (info->proxy) !=
|
||||
GTK_ACTION_GET_CLASS (action)->toolbar_item_type)
|
||||
if (info->proxy &&
|
||||
G_OBJECT_TYPE (info->proxy) != GTK_ACTION_GET_CLASS (action)->toolbar_item_type)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (info->proxy,
|
||||
G_CALLBACK (update_smart_separators),
|
||||
@ -2362,6 +2392,7 @@ update_node (GtkUIManager *self,
|
||||
gtk_action_disconnect_proxy (info->action, info->proxy);
|
||||
gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
|
||||
info->proxy);
|
||||
g_object_unref (info->proxy);
|
||||
info->proxy = NULL;
|
||||
}
|
||||
/* create proxy if needed ... */
|
||||
@ -2373,6 +2404,8 @@ update_node (GtkUIManager *self,
|
||||
if (find_toolbar_position (node, &toolbar, &pos))
|
||||
{
|
||||
info->proxy = gtk_action_create_tool_item (action);
|
||||
g_object_ref (info->proxy);
|
||||
gtk_object_sink (info->proxy);
|
||||
gtk_widget_set_name (info->proxy, info->name);
|
||||
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
|
||||
@ -2408,6 +2441,7 @@ update_node (GtkUIManager *self,
|
||||
{
|
||||
gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
|
||||
info->proxy);
|
||||
g_object_unref (info->proxy);
|
||||
info->proxy = NULL;
|
||||
}
|
||||
|
||||
@ -2416,6 +2450,8 @@ update_node (GtkUIManager *self,
|
||||
GtkToolItem *item = gtk_separator_tool_item_new ();
|
||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, pos);
|
||||
info->proxy = GTK_WIDGET (item);
|
||||
g_object_ref (info->proxy);
|
||||
gtk_object_sink (info->proxy);
|
||||
gtk_widget_set_no_show_all (info->proxy, TRUE);
|
||||
g_object_set_data (G_OBJECT (info->proxy),
|
||||
"gtk-separator-mode",
|
||||
@ -2432,12 +2468,15 @@ update_node (GtkUIManager *self,
|
||||
{
|
||||
gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
|
||||
info->proxy);
|
||||
g_object_unref (info->proxy);
|
||||
info->proxy = NULL;
|
||||
}
|
||||
|
||||
if (find_menu_position (node, &menushell, &pos))
|
||||
{
|
||||
info->proxy = gtk_separator_menu_item_new ();
|
||||
g_object_ref (info->proxy);
|
||||
gtk_object_sink (info->proxy);
|
||||
gtk_widget_set_no_show_all (info->proxy, TRUE);
|
||||
g_object_set_data (G_OBJECT (info->proxy),
|
||||
"gtk-separator-mode",
|
||||
|
@ -203,7 +203,12 @@ static const gchar *ui_info =
|
||||
" <toolitem name=\"justify-fill\" action=\"justify-fill\" />\n"
|
||||
" <separator name=\"sep11\"/>\n"
|
||||
" <toolitem name=\"quit\" action=\"quit\" />\n"
|
||||
" </toolbar>\n";
|
||||
" </toolbar>\n"
|
||||
" <popup name=\"popup\">\n"
|
||||
" <menuitem name=\"popcut\" action=\"cut\" />\n"
|
||||
" <menuitem name=\"popcopy\" action=\"copy\" />\n"
|
||||
" <menuitem name=\"poppaste\" action=\"paste\" />\n"
|
||||
" </popup>\n";
|
||||
|
||||
static void
|
||||
add_widget (GtkUIManager *merge,
|
||||
@ -308,16 +313,18 @@ create_window (GtkActionGroup *action_group)
|
||||
GtkWidget *hbox, *spinbutton, *button;
|
||||
GError *error = NULL;
|
||||
|
||||
merge = gtk_ui_manager_new ();
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), -1, -1);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Action Test");
|
||||
g_signal_connect_swapped (window, "destroy", G_CALLBACK (g_object_unref), merge);
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
|
||||
|
||||
box = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), box);
|
||||
gtk_widget_show (box);
|
||||
|
||||
merge = gtk_ui_manager_new ();
|
||||
gtk_ui_manager_insert_action_group (merge, action_group, 0);
|
||||
g_signal_connect (merge, "add_widget", G_CALLBACK (add_widget), box);
|
||||
|
||||
@ -382,6 +389,21 @@ main (int argc, char **argv)
|
||||
|
||||
gtk_main ();
|
||||
|
||||
#ifdef DEBUG_UI_MANAGER
|
||||
{
|
||||
GList *action;
|
||||
|
||||
for (action = gtk_action_group_list_actions (action_group);
|
||||
action;
|
||||
action = action->next)
|
||||
{
|
||||
GtkAction *a = action->data;
|
||||
g_print ("action %s ref count %d\n",
|
||||
gtk_action_get_name (a), G_OBJECT (a)->ref_count);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
g_object_unref (action_group);
|
||||
|
||||
gtk_accel_map_save ("accels");
|
||||
|
@ -88,7 +88,6 @@ delayed_toggle_dynamic (GtkUIManager *merge)
|
||||
"label", "Dynamic action 2",
|
||||
"stock_id", GTK_STOCK_EXECUTE,
|
||||
NULL);
|
||||
g_object_set (dyn, "name", "dyn2", NULL);
|
||||
gtk_action_group_add_action (dynamic, dyn);
|
||||
}
|
||||
|
||||
@ -690,8 +689,41 @@ main (int argc, char **argv)
|
||||
gtk_widget_show_all (window);
|
||||
gtk_main ();
|
||||
|
||||
g_object_unref (action_group);
|
||||
#ifdef DEBUG_UI_MANAGER
|
||||
{
|
||||
GList *action;
|
||||
|
||||
g_print ("\n> before unreffing the ui manager <\n");
|
||||
for (action = gtk_action_group_list_actions (action_group);
|
||||
action;
|
||||
action = action->next)
|
||||
{
|
||||
GtkAction *a = action->data;
|
||||
g_print (" action %s ref count %d\n",
|
||||
gtk_action_get_name (a), G_OBJECT (a)->ref_count);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
g_object_unref (merge);
|
||||
|
||||
#ifdef DEBUG_UI_MANAGER
|
||||
{
|
||||
GList *action;
|
||||
|
||||
g_print ("\n> after unreffing the ui manager <\n");
|
||||
for (action = gtk_action_group_list_actions (action_group);
|
||||
action;
|
||||
action = action->next)
|
||||
{
|
||||
GtkAction *a = action->data;
|
||||
g_print (" action %s ref count %d\n",
|
||||
gtk_action_get_name (a), G_OBJECT (a)->ref_count);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
g_object_unref (action_group);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user