From 316b24e0a093b8e05ff27e189b896187b4a31bfa Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 28 Nov 2016 15:00:10 -0500 Subject: [PATCH] Fix reference handling in GtkScaleButton We were leaking the adjustment, since we confuse ourselves with a property whose initial value comes out of a template. Stop doing that. https://bugzilla.gnome.org/show_bug.cgi?id=775212 --- gtk/gtkscalebutton.c | 5 +++-- gtk/ui/gtkscalebutton.ui | 6 ------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c index 81a689ef26..27d668ac5e 100644 --- a/gtk/gtkscalebutton.c +++ b/gtk/gtkscalebutton.c @@ -334,7 +334,6 @@ gtk_scale_button_class_init (GtkScaleButtonClass *klass) gtk_widget_class_bind_template_child_private (widget_class, GtkScaleButton, box); gtk_widget_class_bind_template_child_private (widget_class, GtkScaleButton, scale); gtk_widget_class_bind_template_child_private (widget_class, GtkScaleButton, image); - gtk_widget_class_bind_template_child_private (widget_class, GtkScaleButton, adjustment); gtk_widget_class_bind_template_callback (widget_class, cb_button_press); gtk_widget_class_bind_template_callback (widget_class, cb_button_release); @@ -362,7 +361,9 @@ gtk_scale_button_init (GtkScaleButton *button) gtk_popover_set_relative_to (GTK_POPOVER (priv->dock), GTK_WIDGET (button)); /* Need a local reference to the adjustment */ - g_object_ref (priv->adjustment); + priv->adjustment = gtk_adjustment_new (0, 0, 100, 2, 20, 0); + g_object_ref_sink (priv->adjustment); + gtk_range_set_adjustment (GTK_RANGE (priv->scale), priv->adjustment); gtk_widget_add_events (GTK_WIDGET (button), GDK_SMOOTH_SCROLL_MASK); diff --git a/gtk/ui/gtkscalebutton.ui b/gtk/ui/gtkscalebutton.ui index 44373ca3fb..1594d86b81 100644 --- a/gtk/ui/gtkscalebutton.ui +++ b/gtk/ui/gtkscalebutton.ui @@ -15,11 +15,6 @@ - - 100 - 2 - 20 -