summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-05-21 16:23:42 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-05-21 16:23:42 -0400
commit98178d8823562bec5291857b1b2a71c6dd1d3dda (patch)
tree216cb0377471336750ad359dbb9bfae7037b84d8
parent3f6dd34b18b21c08457bb466522d04347c48a55a (diff)
downloadgtk+-98178d8823562bec5291857b1b2a71c6dd1d3dda.tar.gz
gtk-demo: Plug another leak
We were leaking the builder in the revealers demo, by creating a ref cycle. This was showing up as the list entry not going back to upright after closing the window.
-rw-r--r--demos/gtk-demo/revealer.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/demos/gtk-demo/revealer.c b/demos/gtk-demo/revealer.c
index 25f5fcd40b..0f7d097952 100644
--- a/demos/gtk-demo/revealer.c
+++ b/demos/gtk-demo/revealer.c
@@ -25,13 +25,12 @@ static gboolean
reveal_one (gpointer data)
{
GtkWidget *window = data;
- GtkBuilder *builder;
gchar *name;
GtkRevealer *revealer;
- builder = GTK_BUILDER (g_object_get_data (G_OBJECT (window), "builder"));
name = g_strdup_printf ("revealer%d", count);
- revealer = (GtkRevealer *)gtk_builder_get_object (builder, name);
+ revealer = GTK_REVEALER (g_object_get_data (G_OBJECT (window), name));
+ g_free (name);
gtk_revealer_set_reveal_child (revealer, TRUE);
@@ -59,6 +58,7 @@ on_destroy (gpointer data)
g_source_remove (timeout);
timeout = 0;
}
+
}
GtkWidget *
@@ -67,14 +67,23 @@ do_revealer (GtkWidget *do_widget)
if (!window)
{
GtkBuilder *builder;
+ int i;
builder = gtk_builder_new_from_resource ("/revealer/revealer.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
+ for (i = 0; i < 10; i++)
+ {
+ char *name = g_strdup_printf ("revealer%d", i);
+ GtkWidget *revealer = GTK_WIDGET (gtk_builder_get_object (builder, name));
+ g_object_set_data (G_OBJECT (window), name, revealer);
+ g_free (name);
+ }
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_signal_connect (window, "destroy",
G_CALLBACK (on_destroy), NULL);
- g_object_set_data_full (G_OBJECT (window), "builder", builder, g_object_unref);
+
+ g_object_unref (builder);
}
if (!gtk_widget_get_visible (window))