From f3597af5adcd2275503e9e4bfb425549f9ab3ced Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Mon, 12 Nov 2012 21:10:21 +0100 Subject: Fix zero-duration animations running Backwards. If you set the duration of any variant or property animation to 0, its progress will be stuck at 1 (0..1), and its "end" value set on the target object, after start() has been called. If you change the direction of the animation to QAbstractAnimation::Backward, you would expect the progress to be 0 after start. Instead it's still 1; the code seems to assume that if the duration is 0, the progress must be 1 always. The fix is that if the duration is 0, the direction is checked to determine whether progress should be 0 (Backward) or 1 (Forward). Task-number: QTBUG-27969 Change-Id: Ibeca084bbbce41df1dca7b7d96c15b6b54394996 Reviewed-by: Thiago Macieira Reviewed-by: Thierry Bastian Reviewed-by: Magne Zachrisen Reviewed-by: Olivier Goffart --- src/corelib/animation/qvariantanimation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib/animation') diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index e2b6fdf70c..5a3641f3de 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -240,7 +240,8 @@ void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/) if ((keyValues.count() + (defaultStartEndValue.isValid() ? 1 : 0)) < 2) return; - const qreal progress = easing.valueForProgress(((duration == 0) ? qreal(1) : qreal(currentTime) / qreal(duration))); + const qreal endProgress = (direction == QAbstractAnimation::Forward) ? qreal(1) : qreal(0); + const qreal progress = easing.valueForProgress(((duration == 0) ? endProgress : qreal(currentTime) / qreal(duration))); //0 and 1 are still the boundaries if (force || (currentInterval.start.first > 0 && progress < currentInterval.start.first) -- cgit v1.2.3