Fix some leaks. (#348108, Chris Wilson)

2006-12-22  Matthias Clasen  <mclasen@redhat.com>

        * demos/gtk-demo/*.c: Fix some leaks.  (#348108, Chris
        Wilson)

2
This commit is contained in:
Matthias Clasen 2006-12-23 02:39:45 +00:00 committed by Matthias Clasen
parent 721c3bc101
commit 73614da57c
8 changed files with 56 additions and 11 deletions

View File

@ -1,3 +1,8 @@
2006-12-22 Matthias Clasen <mclasen@redhat.com>
* demos/gtk-demo/*.c: Fix some leaks. (#348108, Chris
Wilson)
2006-12-22 Matthias Clasen <mclasen@redhat.com>
* *.c: Replace a lot of idle and timeout calls by

View File

@ -467,6 +467,7 @@ do_appwindow (GtkWidget *do_widget)
"stock-id", GTK_STOCK_OPEN,
NULL);
gtk_action_group_add_action (action_group, open_action);
g_object_unref (open_action);
gtk_action_group_add_actions (action_group,
entries, n_entries,
window);
@ -490,6 +491,7 @@ do_appwindow (GtkWidget *do_widget)
gtk_ui_manager_insert_action_group (merge, action_group, 0);
gtk_window_add_accel_group (GTK_WINDOW (window),
gtk_ui_manager_get_accel_group (merge));
g_object_unref (open_action);
if (!gtk_ui_manager_add_ui_from_string (merge, ui_info, -1, &error))
{

View File

@ -300,6 +300,8 @@ display_changed_cb (GtkTreeSelection *selection,
GtkTreeModel *model;
GtkTreeIter iter;
if (info->current_display)
g_object_unref (info->current_display);
if (gtk_tree_selection_get_selected (selection, &model, &iter))
gtk_tree_model_get (model, &iter,
DISPLAY_COLUMN_DISPLAY, &info->current_display,
@ -320,6 +322,8 @@ screen_changed_cb (GtkTreeSelection *selection,
GtkTreeModel *model;
GtkTreeIter iter;
if (info->current_screen)
g_object_unref (info->current_screen);
if (gtk_tree_selection_get_selected (selection, &model, &iter))
gtk_tree_model_get (model, &iter,
SCREEN_COLUMN_SCREEN, &info->current_screen,
@ -562,6 +566,14 @@ destroy_info (ChangeDisplayInfo *info)
g_slist_free (tmp_list);
g_object_unref (info->size_group);
g_object_unref (info->display_model);
g_object_unref (info->screen_model);
if (info->current_display)
g_object_unref (info->current_display);
if (info->current_screen)
g_object_unref (info->current_screen);
g_free (info);
}

View File

@ -74,6 +74,7 @@ create_stock_icon_store (void)
PIXBUF_COL, pixbuf,
TEXT_COL, label,
-1);
g_object_unref (pixbuf);
g_free (label);
}
else

View File

@ -218,6 +218,16 @@ checkerboard_expose (GtkWidget *da,
return TRUE;
}
static void
close_window (void)
{
window = NULL;
if (pixmap)
g_object_unref (pixmap);
pixmap = NULL;
}
GtkWidget *
do_drawingarea (GtkWidget *do_widget)
{
@ -233,7 +243,7 @@ do_drawingarea (GtkWidget *do_widget)
gtk_widget_get_screen (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Drawing Area");
g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
g_signal_connect (window, "destroy", G_CALLBACK (close_window), NULL);
gtk_container_set_border_width (GTK_CONTAINER (window), 8);
@ -309,14 +319,9 @@ do_drawingarea (GtkWidget *do_widget)
}
if (!GTK_WIDGET_VISIBLE (window))
{
gtk_widget_show_all (window);
}
else
{
gtk_widget_destroy (window);
window = NULL;
}
return window;
}

View File

@ -243,6 +243,18 @@ home_clicked (GtkToolItem *item,
TRUE);
}
static void close_window(void)
{
gtk_widget_destroy (window);
window = NULL;
g_object_unref (file_pixbuf);
file_pixbuf = NULL;
g_object_unref (folder_pixbuf);
folder_pixbuf = NULL;
}
GtkWidget *
do_iconview (GtkWidget *do_widget)
{
@ -258,7 +270,7 @@ do_iconview (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "GtkIconView demo");
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
G_CALLBACK (close_window), NULL);
error = NULL;
if (!load_pixbufs (&error))

View File

@ -782,6 +782,8 @@ create_tree (void)
gtk_widget_grab_focus (tree_view);
g_object_unref (model);
return box;
}
@ -865,7 +867,7 @@ main (int argc, char **argv)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "GTK+ Code Demos");
g_signal_connect (window, "destroy",
g_signal_connect_after (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
hbox = gtk_hbox_new (FALSE, 0);
@ -881,13 +883,15 @@ main (int argc, char **argv)
create_text (&info_buffer, FALSE),
gtk_label_new_with_mnemonic ("_Info"));
tag = gtk_text_buffer_create_tag (info_buffer, "title",
"font", "Sans 18",
NULL);
g_object_unref (info_buffer);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
create_text (&source_buffer, TRUE),
gtk_label_new_with_mnemonic ("_Source"));
tag = gtk_text_buffer_create_tag (info_buffer, "title",
"font", "Sans 18",
NULL);
tag = gtk_text_buffer_create_tag (source_buffer, "comment",
"foreground", "DodgerBlue",
@ -910,6 +914,7 @@ main (int argc, char **argv)
"weight", PANGO_WEIGHT_BOLD,
"foreground", "DarkGoldenrod4",
NULL);
g_object_unref (source_buffer);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
gtk_widget_show_all (window);

View File

@ -183,11 +183,13 @@ do_ui_manager (GtkWidget *do_widget)
ui = gtk_ui_manager_new ();
gtk_ui_manager_insert_action_group (ui, actions, 0);
g_object_unref (actions);
gtk_window_add_accel_group (GTK_WINDOW (window),
gtk_ui_manager_get_accel_group (ui));
gtk_window_set_title (GTK_WINDOW (window), "UI Manager");
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, &error))
{
g_message ("building menus failed: %s", error->message);
@ -223,6 +225,7 @@ do_ui_manager (GtkWidget *do_widget)
gtk_widget_grab_default (button);
gtk_widget_show_all (window);
g_object_unref (ui);
}
else
{