master-clock: Take a reference before advancing timelines
authorEmmanuele Bassi <ebassi@linux.intel.com>
Wed, 11 Nov 2009 11:00:29 +0000 (11:00 +0000)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 4 Jan 2010 11:30:28 +0000 (11:30 +0000)
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

index 8aa8e5e..f278c13 100644 (file)
@@ -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);
 }
 
 /**