diff options
author | Troels Nilsson <nilsson.troels@gmail.com> | 2015-01-21 14:18:35 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2015-02-11 18:36:10 +0000 |
commit | c6f0e3967992780e7786d6bdd90b21149009f2fd (patch) | |
tree | 47b29cc8cbc8166889bbc060cbb22e65d140f0c5 /src/qml/types | |
parent | 890082091b93dae1df895eda92bbb64675d29fbc (diff) |
Fix QML Timer running not being updated together with triggered signal
The running property of the QML Timer should be updated at the same
time as the triggered signal is emitted, otherwise code like e.g. the following:
if (qmlTimer.running)
{
qmlTimer.stop()
}
doesn't work as expected. In addition if the timer is stopped or restarted
between posting the QEvent_Triggered event and receiving it, the triggered
event should not be emitted. This avoids the issue of stopped timers still
emitting the triggered signal which can potentially cause problems in
existing code.
Task-number: QTBUG-44026
Change-Id: Ia14d80d152967d09adc1586467715b2e1c6662cc
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/qml/types')
-rw-r--r-- | src/qml/types/qqmltimer.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/qml/types/qqmltimer.cpp b/src/qml/types/qqmltimer.cpp index ddadd6cc91..8cbcf7a349 100644 --- a/src/qml/types/qqmltimer.cpp +++ b/src/qml/types/qqmltimer.cpp @@ -329,7 +329,11 @@ bool QQmlTimer::event(QEvent *e) ticked(); return true; } else if (e->type() == QEvent_Triggered) { - emit triggered(); + if (d->running && d->pause.isStopped()) { + d->running = false; + emit triggered(); + emit runningChanged(); + } return true; } return QObject::event(e); @@ -340,10 +344,8 @@ void QQmlTimerPrivate::animationFinished(QAbstractAnimationJob *) Q_Q(QQmlTimer); if (repeating || !running) return; - running = false; firstTick = false; QCoreApplication::postEvent(q, new QEvent(QEvent_Triggered)); - emit q->runningChanged(); } QT_END_NAMESPACE |