From 2be42c333ae621df085005e08b7c5c08c02dcbe5 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Mon, 29 Apr 2013 14:59:20 +0100 Subject: [PATCH] ClutterDragAction: do not dereference a NULL priv->stage When destroying an actor during a drag-action with a drag_handle, the ClutterDragAction's priv->stage could be set to NULL in _set_actor(). _dispose() must not assume that priv->stage is not NULL. See also https://bugzilla.gnome.org/show_bug.cgi?id=681814 --- clutter/clutter-drag-action.c | 48 ++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/clutter/clutter-drag-action.c b/clutter/clutter-drag-action.c index 7e1a60009..3d3ff5747 100644 --- a/clutter/clutter-drag-action.c +++ b/clutter/clutter-drag-action.c @@ -657,30 +657,38 @@ clutter_drag_action_dispose (GObject *gobject) /* if we're being disposed while a capture is still present, we * need to reset the state we are currently holding */ - if (priv->last_motion_device != NULL) + if (priv->stage != NULL) + { + if (priv->last_motion_device != NULL) + { + _clutter_stage_remove_pointer_drag_actor (priv->stage, + priv->last_motion_device); + priv->last_motion_device = NULL; + } + + if (priv->sequence != NULL) + { + _clutter_stage_remove_touch_drag_actor (priv->stage, + priv->sequence); + priv->sequence = NULL; + } + + if (priv->capture_id != 0) + { + clutter_stage_set_motion_events_enabled (priv->stage, + priv->motion_events_enabled); + + g_signal_handler_disconnect (priv->stage, priv->capture_id); + + priv->capture_id = 0; + priv->stage = NULL; + } + } + else { - _clutter_stage_remove_pointer_drag_actor (priv->stage, - priv->last_motion_device); priv->last_motion_device = NULL; - } - - if (priv->sequence != NULL) - { - _clutter_stage_remove_touch_drag_actor (priv->stage, - priv->sequence); priv->sequence = NULL; - } - - if (priv->capture_id != 0) - { - clutter_stage_set_motion_events_enabled (priv->stage, - priv->motion_events_enabled); - - if (priv->stage != NULL) - g_signal_handler_disconnect (priv->stage, priv->capture_id); - priv->capture_id = 0; - priv->stage = NULL; } if (priv->button_press_id != 0)