From 1c69c61745ed510f0b6ab16cb963ca01994cb9fc Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 11 Nov 2009 11:00:29 +0000 Subject: [PATCH] master-clock: Take a reference before advancing timelines A timeline advancement might cause another timeline to be destroyed, which will likely lead to a segmentation fault. Before advancing the timelines we should take a reference on them - just like we do for the stages before doing event processing. This will prevent dispose() from running until the end of the advancement. http://bugzilla.openedhand.com/show_bug.cgi?id=1854 --- clutter/clutter-master-clock.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/clutter/clutter-master-clock.c b/clutter/clutter-master-clock.c index 8aa8e5ed0..f278c13db 100644 --- a/clutter/clutter-master-clock.c +++ b/clutter/clutter-master-clock.c @@ -429,12 +429,19 @@ _clutter_master_clock_advance (ClutterMasterClock *master_clock) g_return_if_fail (CLUTTER_IS_MASTER_CLOCK (master_clock)); + /* we protect ourselves from timelines being removed during + * the advancement by other timelines + */ + g_slist_foreach (master_clock->timelines, (GFunc) g_object_ref, NULL); + for (l = master_clock->timelines; l != NULL; l = next) { next = l->next; clutter_timeline_do_tick (l->data, &master_clock->cur_tick); } + + g_slist_foreach (master_clock->timelines, (GFunc) g_object_unref, NULL); } /**