summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorLeonardo Sobral Cunha <leo.cunha@nokia.com>2009-04-21 13:39:37 (GMT)
committerLeonardo Sobral Cunha <leo.cunha@nokia.com>2009-04-22 15:50:40 (GMT)
commitebda84cd06faaf440a096bda7966fa795ca86318 (patch)
treed50c19f9c3cd5b56e857aa35da788244fafdc4c7 /src/corelib
parent6504e06561b9127eb6179b5a5deb8f6cd1fff491 (diff)
downloadQt-ebda84cd06faaf440a096bda7966fa795ca86318.zip
Qt-ebda84cd06faaf440a096bda7966fa795ca86318.tar.gz
Qt-ebda84cd06faaf440a096bda7966fa795ca86318.tar.bz2
Fixes QPropertyAnimation's default start value update condition
The default start value is updated when the animation changes from Stopped to Running state. Reviewed-by: Jan-Arve
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp22
-rw-r--r--src/corelib/animation/qvariantanimation_p.h14
2 files changed, 16 insertions, 20 deletions
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index edcabaa..9a0c5bc 100644
--- a/src/corelib/animation/qpropertyanimation.cpp
+++ b/src/corelib/animation/qpropertyanimation.cpp
@@ -49,7 +49,7 @@
by itself as a simple animation class, or as part of more complex
animations through QAnimationGroup.
- The most common way to use QPropertyAnimation is to construct an instance
+ The most common way to use QPropertyAnimation is to construct an instance
of it by passing a pointer to a QObject or a QWidget, and the name of the
property you would like to animate to QPropertyAnimation's constructor.
@@ -220,11 +220,20 @@ void QPropertyAnimation::updateCurrentValue(const QVariant &value)
/*!
\reimp
+
+ If the startValue is not defined when the state of the animation changes from Stopped to Running,
+ the current property value is used as the initial value for the animation.
*/
void QPropertyAnimation::updateState(QAbstractAnimation::State oldState,
QAbstractAnimation::State newState)
{
Q_D(QPropertyAnimation);
+
+ if (!d->target) {
+ qWarning("QPropertyAnimation::updateState: Changing state of an animation without target");
+ return;
+ }
+
QVariantAnimation::updateState(oldState, newState);
QMutexLocker locker(guardHashLock());
QPropertyAnimationHash * hash = _q_runningAnimations();
@@ -235,20 +244,19 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState,
if (oldAnim) {
// try to stop the top level group
QAbstractAnimation *current = oldAnim;
- while(current->group() && current->state() != Stopped) current = current->group();
+ while (current->group() && current->state() != Stopped)
+ current = current->group();
current->stop();
}
hash->insert(key, this);
- // Initialize start value
- // ### review this line below, d->atEnd() ?
- // ### avoid entering a state where start value is not set
- if (d->target && (d->atBeginning() || d->atEnd())) {
+
+ // update the default start value
+ if (oldState == Stopped) {
d->setDefaultStartValue(d->target->property(d->propertyName.constData()));
}
} else if (hash->value(key) == this) {
hash->remove(key);
}
-
}
#include "moc_qpropertyanimation.cpp"
diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h
index 66910c1..14a3ef6 100644
--- a/src/corelib/animation/qvariantanimation_p.h
+++ b/src/corelib/animation/qvariantanimation_p.h
@@ -88,18 +88,6 @@ public:
return q->d_func();
}
-
- //some helper functions
- bool atBeginning() const
- {
- return currentTime == 0;
- }
-
- bool atEnd() const
- {
- return currentTime == duration && currentLoop == (loopCount - 1);
- }
-
void setDefaultStartValue(const QVariant &value);
int duration;
@@ -109,7 +97,7 @@ public:
QVariant currentValue;
QVariant defaultStartValue;
bool hasStartValue;
-
+
//this is used to keep track of the KeyValue interval in which we currently are
struct
{