[clutter/clutter-1.10] actor: Fix completed transitions logic



commit 32e6eb08aef7421ae3ce00b53a0b9c9a548098fb
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Wed Apr 11 13:57:06 2012 +0100

    actor: Fix completed transitions logic
    
    We need to remove the transition only if the current repeat is equal to
    the number of repeats, and if the transition was marked as remove on
    complete. Otherwise, the transition has to remain where it is.

 clutter/clutter-actor.c |   32 +++++++++++++++++++++-----------
 1 files changed, 21 insertions(+), 11 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 72a3378..7f78762 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -17038,25 +17038,35 @@ static void
 on_transition_completed (ClutterTransition *transition,
                          TransitionClosure *clos)
 {
+  ClutterTimeline *timeline = CLUTTER_TIMELINE (transition);
   ClutterActor *actor = clos->actor;
   ClutterAnimationInfo *info;
+  gint n_repeats, cur_repeat;
+
+  info = _clutter_actor_get_animation_info (actor);
 
   /* reset the caches used by animations */
   clutter_actor_store_content_box (actor, NULL);
 
-  info = _clutter_actor_get_animation_info (actor);
+  /* 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);
 
-  /* this will take care of cleaning clos for us */
-  if (clutter_transition_get_remove_on_complete (transition))
+  if (cur_repeat == n_repeats)
     {
-      /* we take a reference here because removing the closure
-       * will release the reference on the transition, and we
-       * want the transition to survive the signal emission;
-       * the master clock will release the laste reference at
-       * the end of the frame processing.
-       */
-      g_object_ref (transition);
-      g_hash_table_remove (info->transitions, clos->name);
+      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
+           * want the transition to survive the signal emission;
+           * the master clock will release the last reference at
+           * the end of the frame processing.
+           */
+          g_object_ref (transition);
+          g_hash_table_remove (info->transitions, clos->name);
+        }
     }
 
   /* if it's the last transition then we clean up */



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