summaryrefslogtreecommitdiff
path: root/demos/gtk-demo
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2006-12-23 02:39:45 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2006-12-23 02:39:45 +0000
commit73614da57c255eda97ea01d7e9a39ae9b33648a3 (patch)
treef84c777468d8a4dc576130a20affee5f17bb17cb /demos/gtk-demo
parent721c3bc10182cacf1a98baddde3c94e59797ddb7 (diff)
downloadgtk+-73614da57c255eda97ea01d7e9a39ae9b33648a3.tar.gz
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
Diffstat (limited to 'demos/gtk-demo')
-rw-r--r--demos/gtk-demo/appwindow.c2
-rw-r--r--demos/gtk-demo/changedisplay.c12
-rw-r--r--demos/gtk-demo/combobox.c1
-rw-r--r--demos/gtk-demo/drawingarea.c17
-rw-r--r--demos/gtk-demo/iconview.c14
-rw-r--r--demos/gtk-demo/main.c13
-rw-r--r--demos/gtk-demo/ui_manager.c3
7 files changed, 51 insertions, 11 deletions
diff --git a/demos/gtk-demo/appwindow.c b/demos/gtk-demo/appwindow.c
index 6e0f36ecb7..d2ed060558 100644
--- a/demos/gtk-demo/appwindow.c
+++ b/demos/gtk-demo/appwindow.c
@@ -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))
{
diff --git a/demos/gtk-demo/changedisplay.c b/demos/gtk-demo/changedisplay.c
index 11500876c9..32a1e983da 100644
--- a/demos/gtk-demo/changedisplay.c
+++ b/demos/gtk-demo/changedisplay.c
@@ -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);
}
diff --git a/demos/gtk-demo/combobox.c b/demos/gtk-demo/combobox.c
index 7c00630045..99d9681584 100644
--- a/demos/gtk-demo/combobox.c
+++ b/demos/gtk-demo/combobox.c
@@ -74,6 +74,7 @@ create_stock_icon_store (void)
PIXBUF_COL, pixbuf,
TEXT_COL, label,
-1);
+ g_object_unref (pixbuf);
g_free (label);
}
else
diff --git a/demos/gtk-demo/drawingarea.c b/demos/gtk-demo/drawingarea.c
index cde2cc1695..3481a6497f 100644
--- a/demos/gtk-demo/drawingarea.c
+++ b/demos/gtk-demo/drawingarea.c
@@ -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;
}
diff --git a/demos/gtk-demo/iconview.c b/demos/gtk-demo/iconview.c
index 9c76c7815d..6500d2be3c 100644
--- a/demos/gtk-demo/iconview.c
+++ b/demos/gtk-demo/iconview.c
@@ -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))
diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c
index 634a80d6ee..a3b746081b 100644
--- a/demos/gtk-demo/main.c
+++ b/demos/gtk-demo/main.c
@@ -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);
diff --git a/demos/gtk-demo/ui_manager.c b/demos/gtk-demo/ui_manager.c
index 218ff5eccc..5bbdf5c9e8 100644
--- a/demos/gtk-demo/ui_manager.c
+++ b/demos/gtk-demo/ui_manager.c
@@ -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
{