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



commit 487ac50e93a98050b0f9bd26f9a97df37dd06cef
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 7b8da5c..41db024 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -648,8 +648,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
@@ -664,6 +663,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]