[gtk+/gtk-3-22] Fix reference handling in GtkScaleButton



commit 17ec4f10e48a7d540954338d6d07876e01c20bf7
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Nov 28 15:00:10 2016 -0500

    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 81a689e..27d668a 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 44373ca..1594d86 100644
--- a/gtk/ui/gtkscalebutton.ui
+++ b/gtk/ui/gtkscalebutton.ui
@@ -15,11 +15,6 @@
       </object>
     </child>
   </template>
-  <object class="GtkAdjustment" id="adjustment">
-    <property name="upper">100</property>
-    <property name="step-increment">2</property>
-    <property name="page-increment">20</property>
-  </object>
   <object class="GtkPopover" id="dock">
     <signal name="map" handler="cb_popup_mapped" swapped="no"/>
     <style>
@@ -63,7 +58,6 @@
             <property name="visible">1</property>
             <property name="can-focus">1</property>
             <property name="orientation">vertical</property>
-            <property name="adjustment">adjustment</property>
             <property name="inverted">1</property>
             <property name="round-digits">1</property>
             <property name="draw-value">0</property>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]