Commit 73614da5 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

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
parent 721c3bc1
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
......
......@@ -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))
{
......
......@@ -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);
}
......
......@@ -74,6 +74,7 @@ create_stock_icon_store (void)
PIXBUF_COL, pixbuf,
TEXT_COL, label,
-1);
g_object_unref (pixbuf);
g_free (label);
}
else
......
......@@ -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;
}
......@@ -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))
......
......@@ -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);
......
......@@ -183,10 +183,12 @@ 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))
{
......@@ -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
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment