From d846f5fe6a63ef95d1ce12d573b36521f8defd90 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 3 Feb 2011 11:30:10 +0000 Subject: [PATCH] Add some more sanity checks to clutter_do_event() Silently ignore events on stages during destruction; but print out a warning if clutter_do_event() is being called with a stage-less event. --- clutter/clutter-main.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index f24f0b510..948663ed1 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -2262,14 +2262,28 @@ is_off_stage (ClutterActor *stage, * clutter_do_event * @event: a #ClutterEvent. * - * Processes an event. This function should never be called by applications. + * Processes an event. + * + * The @event must be a valid #ClutterEvent and have a #ClutterStage + * associated to it. + * + * This function is only useful when embedding Clutter inside another + * toolkit, and it should never be called by applications. * * Since: 0.4 */ void clutter_do_event (ClutterEvent *event) { - if (!event->any.stage) + /* we need the stage for the event */ + if (event->any.stage == NULL) + { + g_warning ("%s: Event does not have a stage: discarding.", G_STRFUNC); + return; + } + + /* stages in destruction do not process events */ + if (CLUTTER_ACTOR_IN_DESTRUCTION (event->any.stage)) return; /* Instead of processing events when received, we queue them up to