From 487ac50e93a98050b0f9bd26f9a97df37dd06cef Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 1 May 2014 20:58:13 -0400 Subject: [PATCH] GtkButton: Don't leak the gesture --- gtk/gtkbutton.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 7b8da5c404..41db02427a 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); }