summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-04-29 18:47:46 +0200
committerThierry Bastian <thierry.bastian@nokia.com>2009-04-29 18:50:38 +0200
commitbfc92cacbeeb2d1a5ca39e31ccdb94f9674bd547 (patch)
tree2dee36abb200965cb8a08ebde69aaa292a27a39e /src
parent19e7d27d9c107b69157591edd09a36e87c9d93b2 (diff)
downloadqt4-tools-bfc92cacbeeb2d1a5ca39e31ccdb94f9674bd547.tar.gz
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')
-rw-r--r--src/corelib/animation/qvariantanimation.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp
index 9f8cbf0359..bb6cf1c9ce 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);
}
}