GtkButton: Don't leak the gesture

This commit is contained in:
Matthias Clasen 2014-05-01 20:58:13 -04:00 committed by Carlos Garnacho
parent 616aac8d82
commit 487ac50e93

View File

@ -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);
}