diff options
author | Gunnar Sletta <gunnar.sletta@jollamobile.com> | 2014-04-16 11:11:41 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-24 13:46:52 +0200 |
commit | 9bd69842ed8a03381914733a778fbda0d3d56630 (patch) | |
tree | 2b6aa7ea6420109fc6fa82a4cae84cb985b41eec /src/qml/animations | |
parent | d71fb383337b45c31653e54345bff58cf419af19 (diff) |
Fix nested parallel/sequential animations combined with animators.
The logic for looping uncontrolled animations in
QAbstractAnimationJob::setCurrentTime assumes that uncontrolled
animations return duration == -1, always. The logic falls apart when a
duration gets set while the animation is running. To rememdy this,
update QParallelAnimation's duration to return -1 for this case. This
is also how the sequential group's duration is implemented so these
are now using the same pattern.
Update the logic in parallel animations to flush previous loops in
updateAnimationsTime to handle the case where duration is -1. This
solves the case where we have for instance:
ParallelAnimation
Sequential
YAnimator: duration: 1000
ScriptAction ...
Sequential
Pause duration: 5000 <--- longer than yanimator
ScriptAction ...
Task-number: QTBUG-37246
Change-Id: I7a1ea547b2f3090feb8b1e87aa7ca746151736fa
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'src/qml/animations')
-rw-r--r-- | src/qml/animations/qparallelanimationgroupjob.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/qml/animations/qparallelanimationgroupjob.cpp b/src/qml/animations/qparallelanimationgroupjob.cpp index 80538432ef..f66d4b1826 100644 --- a/src/qml/animations/qparallelanimationgroupjob.cpp +++ b/src/qml/animations/qparallelanimationgroupjob.cpp @@ -61,13 +61,8 @@ int QParallelAnimationGroupJob::duration() const for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { int currentDuration = animation->totalDuration(); - //this takes care of the case where a parallel animation group has controlled and uncontrolled - //animations, and the uncontrolled stop before the controlled - if (currentDuration == -1) - currentDuration = uncontrolledAnimationFinishTime(animation); if (currentDuration == -1) return -1; // Undetermined length - ret = qMax(ret, currentDuration); } @@ -82,6 +77,16 @@ void QParallelAnimationGroupJob::updateCurrentTime(int /*currentTime*/) if (m_currentLoop > m_previousLoop) { // simulate completion of the loop int dura = duration(); + if (dura < 0) { + // For an uncontrolled parallel group, we need to simulate the end of running animations. + // As uncontrolled animation finish time is already reset for this next loop, we pick the + // longest of the known stop times. + for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { + int currentDuration = animation->totalDuration(); + if (currentDuration >= 0) + dura = qMax(dura, currentDuration); + } + } if (dura > 0) { for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { if (!animation->isStopped()) |