Clear pending events for a stage when it is destroyed
authorNeil Roberts <neil@linux.intel.com>
Fri, 13 Nov 2009 13:39:24 +0000 (13:39 +0000)
committerNeil Roberts <neil@linux.intel.com>
Fri, 13 Nov 2009 15:27:38 +0000 (15:27 +0000)
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

index be29412..7a84cd4 100644 (file)
@@ -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");