diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-04-29 16:47:46 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-04-29 16:50:38 (GMT) |
commit | bfc92cacbeeb2d1a5ca39e31ccdb94f9674bd547 (patch) | |
tree | 2dee36abb200965cb8a08ebde69aaa292a27a39e /src/corelib/animation/qvariantanimation.cpp | |
parent | 19e7d27d9c107b69157591edd09a36e87c9d93b2 (diff) | |
download | Qt-bfc92cacbeeb2d1a5ca39e31ccdb94f9674bd547.zip Qt-bfc92cacbeeb2d1a5ca39e31ccdb94f9674bd547.tar.gz Qt-bfc92cacbeeb2d1a5ca39e31ccdb94f9674bd547.tar.bz2 |
Small refactor of QVariantAnimation::updateCurrentValue
we only test the inequality of the new value compared to the previous
one in case we have something conected to currentValueChanged signal.
The comparison is quite heavy in QVariant. So avoiding it a good thing.
Diffstat (limited to 'src/corelib/animation/qvariantanimation.cpp')
-rw-r--r-- | src/corelib/animation/qvariantanimation.cpp | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index 9f8cbf0..bb6cf1c 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -175,26 +175,16 @@ void QVariantAnimationPrivate::updateCurrentValue() endProgress = currentInterval.end.first; const qreal localProgress = (progress - startProgress) / (endProgress - startProgress); - bool changed = false; - { - //we do that here in a limited scope so that ret is dereferenced and frees memory - //and the call to updateCurrentValue can recreate QVariant of the same type (for ex. in - //QGraphicsItem::setPos - QVariant ret = q->interpolated(currentInterval.start.second, - currentInterval.end.second, - localProgress); - if (currentValue != ret) { - changed = true; - qSwap(currentValue, ret); - } - } - - if (changed) { - //the value has changed - q->updateCurrentValue(currentValue); + QVariant ret = q->interpolated(currentInterval.start.second, + currentInterval.end.second, + localProgress); + qSwap(currentValue, ret); + q->updateCurrentValue(currentValue); #ifndef QT_EXPERIMENTAL_SOLUTION if (connectedSignals & changedSignalMask) #endif + if (currentValue != ret) { + //the value has changed emit q->valueChanged(currentValue); } } |