[clutter] actor: Ensure that we correctly remove transitions



commit 97dcfe5bf14de873425b6759954e74096ea3eefb
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Thu Mar 29 12:01:03 2012 +0100

    actor: Ensure that we correctly remove transitions
    
    The check on :remove-on-complete was inverted, but we also need to check
    that the current repeat of the timeline is also the last.

 clutter/clutter-actor.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 084d033..a79549a 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -17025,7 +17025,7 @@ on_transition_completed (ClutterTransition *transition,
   info = _clutter_actor_get_animation_info (actor);
 
   /* this will take care of cleaning clos for us */
-  if (clutter_transition_get_remove_on_complete (transition))
+  if (!clutter_transition_get_remove_on_complete (transition))
     {
       /* we take a reference here because removing the closure
        * will release the reference on the transition, and we
@@ -17036,6 +17036,25 @@ on_transition_completed (ClutterTransition *transition,
       g_object_ref (transition);
       g_hash_table_remove (info->transitions, clos->name);
     }
+  else
+    {
+      ClutterTimeline *timeline = CLUTTER_TIMELINE (transition);
+      gint n_repeats, cur_repeat;
+
+      /* ensure that we remove the transition only at the end
+       * of its run; we emit ::completed for every repeat
+       */
+
+      n_repeats = clutter_timeline_get_repeat_count (timeline);
+      cur_repeat = clutter_timeline_get_current_repeat (timeline);
+
+      if (cur_repeat == n_repeats)
+        {
+          /* see the comment above on why this ref() is necessary */
+          g_object_ref (transition);
+          g_hash_table_remove (info->transitions, clos->name);
+        }
+    }
 
   /* if it's the last transition then we clean up */
   if (g_hash_table_size (info->transitions) == 0)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]