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
This commit is contained in:
Neil Roberts 2009-11-13 13:39:24 +00:00
parent 49cd887aab
commit 568ad044eb

View File

@ -704,11 +704,29 @@ clutter_stage_dispose (GObject *object)
ClutterStage *stage = CLUTTER_STAGE (object); ClutterStage *stage = CLUTTER_STAGE (object);
ClutterStagePrivate *priv = stage->priv; ClutterStagePrivate *priv = stage->priv;
ClutterStageManager *stage_manager = clutter_stage_manager_get_default (); ClutterStageManager *stage_manager = clutter_stage_manager_get_default ();
ClutterMainContext *context;
GList *l, *next;
clutter_actor_hide (CLUTTER_ACTOR (object)); clutter_actor_hide (CLUTTER_ACTOR (object));
_clutter_stage_manager_remove_stage (stage_manager, stage); _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) if (priv->impl != NULL)
{ {
CLUTTER_NOTE (BACKEND, "Disposing of the stage implementation"); CLUTTER_NOTE (BACKEND, "Disposing of the stage implementation");