summaryrefslogtreecommitdiffstats
path: root/src/corelib/animation
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2011-12-12 14:30:11 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-13 02:23:47 +0100
commit08d378d9331c5be75087b1158a50076d12e14ea5 (patch)
tree2e0e4f43d1f502543bb9819097a06ce5fcbafa1e /src/corelib/animation
parent3bd3b82a2f6e61bb9f5bcc095ef96b39d8e19b80 (diff)
Cleanup pause timer handling in QUnifiedTimer.
The animationTimer is now only used for pauses, so can be renamed to pauseTimer, and directly queried for whether it is active. Change-Id: I3d9319b6ee76158e875ab43657126a0aa0a1cf2e Reviewed-by: Leonardo Sobral Cunha <leo.cunha@nokia.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/corelib/animation')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp21
-rw-r--r--src/corelib/animation/qabstractanimation_p.h5
2 files changed, 11 insertions, 15 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index d852fee7f0..1d0715e6d9 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -169,7 +169,7 @@ QUnifiedTimer::QUnifiedTimer() :
QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
currentAnimationIdx(0), insideTick(false), consistentTiming(false), slowMode(false),
startAnimationPending(false), stopTimerPending(false),
- slowdownFactor(5.0f), isPauseTimerActive(false), runningLeafAnimations(0), profilerCallback(0)
+ slowdownFactor(5.0f), runningLeafAnimations(0), profilerCallback(0)
{
time.invalidate();
driver = &defaultDriver;
@@ -201,7 +201,7 @@ QUnifiedTimer *QUnifiedTimer::instance()
void QUnifiedTimer::ensureTimerUpdate()
{
QUnifiedTimer *inst = QUnifiedTimer::instance(false);
- if (inst && inst->isPauseTimerActive)
+ if (inst && inst->pauseTimer.isActive())
inst->updateAnimationsTime(-1);
}
@@ -214,7 +214,7 @@ void QUnifiedTimer::updateAnimationsTime(qint64 timeStep)
qint64 totalElapsed = timeStep >= 0 ? timeStep : time.elapsed();
// ignore consistentTiming in case the pause timer is active
- int delta = (consistentTiming && !isPauseTimerActive) ?
+ int delta = (consistentTiming && !pauseTimer.isActive()) ?
timingInterval : totalElapsed - lastTick;
if (slowMode) {
if (slowdownFactor > 0)
@@ -265,11 +265,11 @@ void QUnifiedTimer::restartAnimationTimer()
qDebug() << closestPauseAnimationTimeToFinish();
}
driver->stop();
- animationTimer.start(closestTimeToFinish, this);
- isPauseTimerActive = true;
- } else if (!driver->isRunning() || isPauseTimerActive) {
+ pauseTimer.start(closestTimeToFinish, this);
+ } else if (!driver->isRunning()) {
+ if (pauseTimer.isActive())
+ pauseTimer.stop();
driver->start();
- isPauseTimerActive = false;
} else if (runningLeafAnimations == 0)
driver->stop();
}
@@ -278,7 +278,7 @@ void QUnifiedTimer::setTimingInterval(int interval)
{
timingInterval = interval;
- if (driver->isRunning() && !isPauseTimerActive) {
+ if (driver->isRunning() && !pauseTimer.isActive()) {
//we changed the timing interval
driver->stop();
driver->start();
@@ -304,8 +304,7 @@ void QUnifiedTimer::stopTimer()
{
stopTimerPending = false;
if (animations.isEmpty()) {
- animationTimer.stop();
- isPauseTimerActive = false;
+ pauseTimer.stop();
// invalidate the start reference time
time.invalidate();
}
@@ -322,7 +321,7 @@ void QUnifiedTimer::timerEvent(QTimerEvent *event)
startAnimations();
}
- if (event->timerId() == animationTimer.timerId()) {
+ if (event->timerId() == pauseTimer.timerId()) {
// update current time on all top level animations
updateAnimationsTime(-1);
restartAnimationTimer();
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index 61a68a7032..e7c1effa9f 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -206,7 +206,7 @@ private:
QAnimationDriver *driver;
QDefaultAnimationDriver defaultDriver;
- QBasicTimer animationTimer;
+ QBasicTimer pauseTimer;
// timer used to delay the check if we should start/stop the animation timer
QBasicTimer startStopAnimationTimer;
@@ -226,9 +226,6 @@ private:
// stops all animations.
qreal slowdownFactor;
- // bool to indicate that only pause animations are active
- bool isPauseTimerActive;
-
QList<QAbstractAnimation*> animations, animationsToStart;
// this is the count of running animations that are not a group neither a pause animation