diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-11-03 06:43:50 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-11-03 06:43:50 (GMT) |
commit | 7bc853890bbd8653c3d058d50811ae6dfaad1fd1 (patch) | |
tree | a32d75808b19c0db9eacdfaf1b6765c545fdb949 /src/declarative/util | |
parent | 88937dc4246006d7a75c2978cd542b11e983c705 (diff) | |
download | Qt-7bc853890bbd8653c3d058d50811ae6dfaad1fd1.zip Qt-7bc853890bbd8653c3d058d50811ae6dfaad1fd1.tar.gz Qt-7bc853890bbd8653c3d058d50811ae6dfaad1fd1.tar.bz2 |
Don't trigger if we've been stopped.
Task-number: QT-2423
Diffstat (limited to 'src/declarative/util')
-rw-r--r-- | src/declarative/util/qmltimer.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/declarative/util/qmltimer.cpp b/src/declarative/util/qmltimer.cpp index 268d5ec..2e844be 100644 --- a/src/declarative/util/qmltimer.cpp +++ b/src/declarative/util/qmltimer.cpp @@ -57,12 +57,12 @@ public: : interval(1000), running(false), repeating(false), triggeredOnStart(false) , classBegun(false), componentComplete(false) {} int interval; - bool running; - bool repeating; - bool triggeredOnStart; QPauseAnimation pause; - bool classBegun; - bool componentComplete; + bool running : 1; + bool repeating : 1; + bool triggeredOnStart : 1; + bool classBegun : 1; + bool componentComplete : 1; }; /*! @@ -82,6 +82,9 @@ public: } \endqml + QmlTimer is synchronized with the animation timer. Since the animation + timer is usually set to 60fps, the resolution of QmlTimer will be + at best 16ms. */ QmlTimer::QmlTimer(QObject *parent) @@ -89,7 +92,6 @@ QmlTimer::QmlTimer(QObject *parent) { Q_D(QmlTimer); connect(&d->pause, SIGNAL(currentLoopChanged(int)), this, SLOT(ticked())); - connect(&d->pause, SIGNAL(finished()), this, SLOT(ticked())); connect(&d->pause, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)) , this, SLOT(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); d->pause.setLoopCount(1); @@ -259,7 +261,9 @@ void QmlTimer::componentComplete() */ void QmlTimer::ticked() { - emit triggered(); + Q_D(QmlTimer); + if (d->running) + emit triggered(); } void QmlTimer::stateChanged(QAbstractAnimation::State, QAbstractAnimation::State state) @@ -267,6 +271,7 @@ void QmlTimer::stateChanged(QAbstractAnimation::State, QAbstractAnimation::State Q_D(QmlTimer); if (d->running && state != QAbstractAnimation::Running) { d->running = false; + emit triggered(); emit runningChanged(); } } |