From 568ad044eba38198ecdb32f671047bffa27353a9 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 13 Nov 2009 13:39:24 +0000 Subject: [PATCH] Clear pending events for a stage when it is destroyed We can not process events for a stage that has been destroyed so we should make sure that the events for the stage are removed from the global event queue during dispose. http://bugzilla.openedhand.com/show_bug.cgi?id=1882 --- clutter/clutter-stage.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index be29412..7a84cd4 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -704,11 +704,29 @@ clutter_stage_dispose (GObject *object) ClutterStage *stage = CLUTTER_STAGE (object); ClutterStagePrivate *priv = stage->priv; ClutterStageManager *stage_manager = clutter_stage_manager_get_default (); + ClutterMainContext *context; + GList *l, *next; clutter_actor_hide (CLUTTER_ACTOR (object)); _clutter_stage_manager_remove_stage (stage_manager, stage); + context = _clutter_context_get_default (); + + /* Remove any pending events for this stage from the event queue */ + for (l = context->events_queue->head; l; l = next) + { + ClutterEvent *event = l->data; + + next = l->next; + + if (event->any.stage == stage) + { + g_queue_delete_link (context->events_queue, l); + clutter_event_free (event); + } + } + if (priv->impl != NULL) { CLUTTER_NOTE (BACKEND, "Disposing of the stage implementation"); -- 2.7.4