From b081df4a405632da3923f66ec32240c12f4acce9 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 28 Sep 2011 10:12:08 +1000 Subject: [PATCH] Use QBasicTimer rather than QTimer in SmoothedAnimation QBasicTimer does the same job for lower cost. Change-Id: I11d7033b9c456129f3f984c8baafa717f5b25d99 Reviewed-on: http://codereview.qt-project.org/5649 Reviewed-by: Qt Sanity Bot Reviewed-by: Michael Brasser --- src/declarative/util/qdeclarativesmoothedanimation.cpp | 15 +++++++++++---- src/declarative/util/qdeclarativesmoothedanimation_p_p.h | 5 +++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/declarative/util/qdeclarativesmoothedanimation.cpp b/src/declarative/util/qdeclarativesmoothedanimation.cpp index d306f8a..dd7bfe2 100644 --- a/src/declarative/util/qdeclarativesmoothedanimation.cpp +++ b/src/declarative/util/qdeclarativesmoothedanimation.cpp @@ -62,9 +62,6 @@ QSmoothedAnimation::QSmoothedAnimation(QObject *parent) reversingMode(QDeclarativeSmoothedAnimation::Eased), initialVelocity(0), trackVelocity(0), initialValue(0), invert(false), finalDuration(-1), lastTime(0) { - delayedStopTimer.setInterval(DELAY_STOP_TIMER_INTERVAL); - delayedStopTimer.setSingleShot(true); - connect(&delayedStopTimer, SIGNAL(timeout()), this, SLOT(stop())); } void QSmoothedAnimation::restart() @@ -82,10 +79,20 @@ void QSmoothedAnimation::updateState(QAbstractAnimation::State newState, QAbstra init(); } +void QSmoothedAnimation::timerEvent(QTimerEvent *event) +{ + if (event->timerId() == delayedStopTimer.timerId()) { + delayedStopTimer.stop(); + stop(); + } else { + QAbstractAnimation::timerEvent(event); + } +} + void QSmoothedAnimation::delayedStop() { if (!delayedStopTimer.isActive()) - delayedStopTimer.start(); + delayedStopTimer.start(DELAY_STOP_TIMER_INTERVAL, this); } int QSmoothedAnimation::duration() const diff --git a/src/declarative/util/qdeclarativesmoothedanimation_p_p.h b/src/declarative/util/qdeclarativesmoothedanimation_p_p.h index 161fb11..224dc75 100644 --- a/src/declarative/util/qdeclarativesmoothedanimation_p_p.h +++ b/src/declarative/util/qdeclarativesmoothedanimation_p_p.h @@ -61,7 +61,7 @@ #include #include -#include +#include QT_BEGIN_NAMESPACE @@ -89,6 +89,7 @@ public: protected: virtual void updateCurrentTime(int); virtual void updateState(QAbstractAnimation::State, QAbstractAnimation::State); + virtual void timerEvent(QTimerEvent *); private: qreal easeFollow(qreal); @@ -115,7 +116,7 @@ private: bool recalc(); void delayedStop(); - QTimer delayedStopTimer; + QBasicTimer delayedStopTimer; }; class QDeclarativeSmoothedAnimationPrivate : public QDeclarativePropertyAnimationPrivate -- 2.7.4