Don't assert in gtk_event_controller_constructed

This prevents some of our generic object implementation tests
from working with gesture objects. Instead, add g_return_if_fail
checks in all the gesture constructors.
This commit is contained in:
Matthias Clasen 2014-05-27 14:30:47 -04:00
parent e4680d64a0
commit 3bb404f40c
7 changed files with 16 additions and 3 deletions

View File

@ -115,8 +115,8 @@ gtk_event_controller_constructed (GObject *object)
GtkEventControllerPrivate *priv;
priv = gtk_event_controller_get_instance_private (controller);
g_assert (priv->widget != NULL);
_gtk_widget_add_controller (priv->widget, controller);
if (priv->widget)
_gtk_widget_add_controller (priv->widget, controller);
}
static void
@ -126,7 +126,8 @@ gtk_event_controller_dispose (GObject *object)
GtkEventControllerPrivate *priv;
priv = gtk_event_controller_get_instance_private (controller);
_gtk_widget_remove_controller (priv->widget, controller);
if (priv->widget)
_gtk_widget_remove_controller (priv->widget, controller);
}
static void

View File

@ -186,6 +186,8 @@ gtk_gesture_drag_init (GtkGestureDrag *gesture)
GtkGesture *
gtk_gesture_drag_new (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
return g_object_new (GTK_TYPE_GESTURE_DRAG,
"widget", widget,
NULL);

View File

@ -262,6 +262,8 @@ gtk_gesture_long_press_class_init (GtkGestureLongPressClass *klass)
GtkGesture *
gtk_gesture_long_press_new (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
return g_object_new (GTK_TYPE_GESTURE_LONG_PRESS,
"widget", widget,
NULL);

View File

@ -384,6 +384,8 @@ gtk_gesture_multi_press_init (GtkGestureMultiPress *gesture)
GtkGesture *
gtk_gesture_multi_press_new (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
return g_object_new (GTK_TYPE_GESTURE_MULTI_PRESS,
"widget", widget,
NULL);

View File

@ -188,6 +188,8 @@ gtk_gesture_rotate_class_init (GtkGestureRotateClass *klass)
GtkGesture *
gtk_gesture_rotate_new (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
return g_object_new (GTK_TYPE_GESTURE_ROTATE,
"widget", widget,
NULL);

View File

@ -237,6 +237,8 @@ gtk_gesture_swipe_init (GtkGestureSwipe *gesture)
GtkGesture *
gtk_gesture_swipe_new (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
return g_object_new (GTK_TYPE_GESTURE_SWIPE,
"widget", widget,
NULL);

View File

@ -181,6 +181,8 @@ gtk_gesture_zoom_class_init (GtkGestureZoomClass *klass)
GtkGesture *
gtk_gesture_zoom_new (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
return g_object_new (GTK_TYPE_GESTURE_ZOOM,
"widget", widget,
NULL);