From 619d049371ac8a180de3d91140bf252f44c25dad Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 21 Oct 2009 10:15:19 +0200 Subject: Improve performance when starting a lot of animations We avoid stopping/starting the timer over and over again Patch suggested by Aaron. Reviewed-by: Aaron Kennedy --- src/corelib/animation/qabstractanimation.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 0d5f278..2f776d3 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -272,7 +272,8 @@ void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation, bool isTopL Q_ASSERT(!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer); QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = true; animationsToStart << animation; - startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this); + if (!startStopAnimationTimer.isActive()) + startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this); } } @@ -290,7 +291,7 @@ void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation) if (idx <= currentAnimationIdx) --currentAnimationIdx; - if (animations.isEmpty()) + if (animations.isEmpty() && !startStopAnimationTimer.isActive()) startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this); } else { animationsToStart.removeOne(animation); -- cgit v0.12