gtk-demo: fix leaks in appwindow, builder and images
This commit is contained in:
parent
827d0f156b
commit
82baa569a2
3 changed files with 18 additions and 0 deletions
|
|
@ -466,6 +466,7 @@ do_appwindow (GtkWidget *do_widget)
|
|||
g_object_set_data_full (G_OBJECT (window), "ui-manager", merge,
|
||||
g_object_unref);
|
||||
gtk_ui_manager_insert_action_group (merge, action_group, 0);
|
||||
g_object_unref (action_group);
|
||||
gtk_window_add_accel_group (GTK_WINDOW (window),
|
||||
gtk_ui_manager_get_accel_group (merge));
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,19 @@ about_activate (GtkAction *action)
|
|||
gtk_widget_hide (about_dlg);
|
||||
}
|
||||
|
||||
/* the about dialog and the builder go with the window */
|
||||
static void
|
||||
window_destroyed (GtkWidget *window,
|
||||
gpointer user_data)
|
||||
{
|
||||
GObject *about_dlg = gtk_builder_get_object (builder, "aboutdialog1");
|
||||
|
||||
if (about_dlg)
|
||||
gtk_widget_destroy (GTK_WIDGET (about_dlg));
|
||||
g_object_unref (builder);
|
||||
builder = NULL;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
do_builder (GtkWidget *do_widget)
|
||||
{
|
||||
|
|
@ -51,6 +64,8 @@ do_builder (GtkWidget *do_widget)
|
|||
gtk_widget_get_screen (do_widget));
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed), &window);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (window_destroyed), NULL);
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
|
|
|
|||
|
|
@ -389,6 +389,8 @@ do_images (GtkWidget *do_widget)
|
|||
}
|
||||
|
||||
image = gtk_image_new_from_pixbuf (pixbuf);
|
||||
if (pixbuf)
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), image);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue