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:
committed by
Matthias Clasen
parent
9aeba99da0
commit
82877f9ee9
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user