[gtk+/gestures: 119/140] GtkButton: Don't leak the gesture



commit 519cdfbb6d554013786af3c88ae79e378751a1ed
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu May 1 20:58:13 2014 -0400

    GtkButton: Don't leak the gesture

 gtk/gtkbutton.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 20dd4cf..f60b3d5 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -642,8 +642,7 @@ gtk_button_init (GtkButton *button)
   gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (priv->gesture), GDK_BUTTON_PRIMARY);
   g_signal_connect (priv->gesture, "begin", G_CALLBACK (gesture_begin_cb), button);
   g_signal_connect (priv->gesture, "end", G_CALLBACK (gesture_end_cb), button);
-  gtk_widget_add_controller (GTK_WIDGET (button),
-                             GTK_EVENT_CONTROLLER (priv->gesture));
+  gtk_widget_add_controller (GTK_WIDGET (button), GTK_EVENT_CONTROLLER (priv->gesture));
 }
 
 static void
@@ -658,6 +657,13 @@ gtk_button_destroy (GtkWidget *widget)
       priv->label_text = NULL;
     }
 
+  if (priv->gesture)
+    {
+      gtk_widget_remove_controller (widget, GTK_EVENT_CONTROLLER (priv->gesture));
+      g_object_unref (priv->gesture);
+      priv->gesture = NULL;
+    }
+
   GTK_WIDGET_CLASS (gtk_button_parent_class)->destroy (widget);
 }
 


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