From 01fd42897353e919335b4e53a1bd4aafbeb854fa Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Thu, 26 Sep 2019 15:32:41 +0100 Subject: [PATCH] (Animation) Fix assert when animation is resumed using PlayAfter after all loops have finished Change-Id: I7342b253e6c2508184b29dc02b4abcf482e1c168 --- automated-tests/src/dali/utc-Dali-Animation.cpp | 39 ++++++++++++++++++++++ .../update/animation/scene-graph-animation.cpp | 4 ++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/automated-tests/src/dali/utc-Dali-Animation.cpp b/automated-tests/src/dali/utc-Dali-Animation.cpp index 41517d1..179ac9b 100644 --- a/automated-tests/src/dali/utc-Dali-Animation.cpp +++ b/automated-tests/src/dali/utc-Dali-Animation.cpp @@ -13454,3 +13454,42 @@ int UtcDaliAnimationPausePropertyValue(void) END_TEST; } + +int UtcDaliAnimationPlayFromWithLoopCount(void) +{ + TestApplication application; + + auto actor = Actor::New(); + Stage::GetCurrent().Add( actor ); + + auto animation = Animation::New( 1.0f ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), 100.0f ); + animation.SetLoopCount( 2 ); + animation.Play(); + + application.SendNotification(); + application.Render( 1001 ); + + // One loop completed + + application.Render( 2005 ); + application.SendNotification(); + + // 2 loops should have completed + DALI_TEST_EQUALS( animation.GetCurrentLoop(), 2u, TEST_LOCATION ); + + // Another render needs to occur after all the loops end + application.SendNotification(); + application.Render( 1000 ); + + // Stop the animation and use PlayFrom, previously we got an Assert here + animation.Stop(); + animation.PlayFrom( 0.5f ); + + application.SendNotification(); + application.Render( 1000 ); + + DALI_TEST_EQUALS( animation.GetState(), Animation::PLAYING, TEST_LOCATION ); + + END_TEST; +} diff --git a/dali/internal/update/animation/scene-graph-animation.cpp b/dali/internal/update/animation/scene-graph-animation.cpp index ad3abd4..167dcaa 100644 --- a/dali/internal/update/animation/scene-graph-animation.cpp +++ b/dali/internal/update/animation/scene-graph-animation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -176,6 +176,8 @@ void Animation::PlayFrom( float progress ) mState = Playing; SetAnimatorsActive( true ); + + mCurrentLoop = 0; } } -- 2.7.4