From eb0ce0d5c123c010c978c96683cfd6b651540b07 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 2 Jan 2012 12:47:15 +0100 Subject: Use explicit Qt::TimerTypes when starting animation timers. Similar to commit 4e1ad49998cf782ccc88e7e80fbd05c722658a16, we know that CoarseTimers are worst in their first firing, so we prefer a PreciseTimer for short pause animations to avoid inaccuracies. If the timeout is too big, we use a CoarseTimer anyway (current threshold is 2000ms). The timer that drives the QDefaultAnimationDriver is always a PreciseTimer. Change-Id: I0939357d768b804f9f9bab3adf5ed1d0f7e012e7 Reviewed-by: Thiago Macieira Reviewed-by: Gunnar Sletta --- src/corelib/animation/qabstractanimation.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 9e4b361883..19a9384132 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -158,6 +158,7 @@ #define DEFAULT_TIMER_INTERVAL 16 #define STARTSTOP_TIMER_DELAY 0 +#define PAUSE_TIMER_COARSE_THRESHOLD 2000 QT_BEGIN_NAMESPACE @@ -264,7 +265,9 @@ void QUnifiedTimer::restartAnimationTimer() qDebug() << closestPauseAnimationTimeToFinish(); } driver->stop(); - pauseTimer.start(closestTimeToFinish, this); + // use a precise timer if the pause will be short + Qt::TimerType timerType = closestTimeToFinish < PAUSE_TIMER_COARSE_THRESHOLD ? Qt::PreciseTimer : Qt::CoarseTimer; + pauseTimer.start(closestTimeToFinish, timerType, this); } else if (!driver->isRunning()) { if (pauseTimer.isActive()) pauseTimer.stop(); @@ -619,7 +622,8 @@ void QDefaultAnimationDriver::timerEvent(QTimerEvent *e) void QDefaultAnimationDriver::startTimer() { - m_timer.start(m_unified_timer->timingInterval, this); + // always use a precise timer to drive animations + m_timer.start(m_unified_timer->timingInterval, Qt::PreciseTimer, this); } void QDefaultAnimationDriver::stopTimer() -- cgit v1.2.3