From 26da6385e1d687cc9aef375cc9b5fb4f6fc353d0 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 11 Sep 2009 11:34:15 +0200 Subject: animations now display a warning if they don't have a end value also improved the autotests --- src/corelib/animation/qpropertyanimation.cpp | 4 ++-- tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index d6ded62..861bd9f 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -273,9 +273,9 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState, if (oldState == Stopped) { d->setDefaultStartEndValue(d->targetValue->property(d->propertyName.constData())); //let's check if we have a start value and an end value - if (d->direction == Forward && !startValue().isValid() && !d->defaultStartEndValue.isValid()) + if (!startValue().isValid() && (d->direction == Backward || !d->defaultStartEndValue.isValid())) qWarning("QPropertyAnimation::updateState: starting an animation without start value"); - if (d->direction == Backward && !endValue().isValid() && !d->defaultStartEndValue.isValid()) + if (!endValue().isValid() && (d->direction == Forward || !d->defaultStartEndValue.isValid())) qWarning("QPropertyAnimation::updateState: starting an animation without end value"); } } else if (hash.value(key) == this) { diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 60bc39e..bea399c 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -473,6 +473,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() { //normal case: the animation finishes and is deleted QPointer anim = new QPropertyAnimation(&o, "ole"); + anim->setEndValue(100); QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim->start(QVariantAnimation::DeleteWhenStopped); QTest::qWait(anim->duration() + 50); @@ -482,10 +483,12 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() { QPointer anim = new QPropertyAnimation(&o, "ole"); + anim->setEndValue(100); QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim->start(QVariantAnimation::DeleteWhenStopped); QTest::qWait(anim->duration()/2); QPointer anim2 = new QPropertyAnimation(&o, "ole"); + anim2->setEndValue(100); QCOMPARE(runningSpy.count(), 1); QCOMPARE(anim->state(), QVariantAnimation::Running); @@ -634,6 +637,7 @@ void tst_QPropertyAnimation::playForwardBackward() QCOMPARE(o.property("ole").toInt(), 0); QPropertyAnimation anim(&o, "ole"); + anim.setStartValue(0); anim.setEndValue(100); anim.start(); QTest::qWait(anim.duration() + 50); @@ -906,6 +910,7 @@ void tst_QPropertyAnimation::operationsInStates() QObject o; o.setProperty("ole", 42); QPropertyAnimation anim(&o, "ole"); + anim.setEndValue(100); QSignalSpy spy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim.stop(); -- cgit v0.12