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.
This commit is contained in:
Emmanuele Bassi 2012-04-11 13:57:06 +01:00
parent 2d48e6e3e4
commit 14b9cb4f7b

View File

@ -17052,41 +17052,32 @@ 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);
}
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)
if (clutter_transition_get_remove_on_complete (transition))
{
/* see the comment above on why this ref() is necessary */
/* 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);
}