summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-05-23 21:37:04 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-05-23 21:37:24 +0200
commit905ecdd78349aac1933e013c5690670221f0b1f3 (patch)
tree779d05ccbf23a5643a946367c78f4631b5284cfb /src/corelib/kernel
parent922d195020d54d7e599d135f6a5e0338100e08f1 (diff)
QBasicTimer: share some code
Saves 0.5KiB on optimized GCC 9.1 Linux AMD64 builds, and is more maintainable going forward. Change-Id: I11e6dd33eacf276d1205a63734c66fa7c70c5118 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qbasictimer.cpp27
1 files changed, 2 insertions, 25 deletions
diff --git a/src/corelib/kernel/qbasictimer.cpp b/src/corelib/kernel/qbasictimer.cpp
index 637c98cd40..13d90c1620 100644
--- a/src/corelib/kernel/qbasictimer.cpp
+++ b/src/corelib/kernel/qbasictimer.cpp
@@ -115,24 +115,7 @@ QT_BEGIN_NAMESPACE
*/
void QBasicTimer::start(int msec, QObject *obj)
{
- QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
- if (Q_UNLIKELY(!eventDispatcher)) {
- qWarning("QBasicTimer::start: QBasicTimer can only be used with threads started with QThread");
- return;
- }
- if (Q_UNLIKELY(obj && obj->thread() != eventDispatcher->thread())) {
- qWarning("QBasicTimer::start: Timers cannot be started from another thread");
- return;
- }
- if (id) {
- if (Q_LIKELY(eventDispatcher->unregisterTimer(id)))
- QAbstractEventDispatcherPrivate::releaseTimerId(id);
- else
- qWarning("QBasicTimer::start: Stopping previous timer failed. Possibly trying to stop from a different thread");
- }
- id = 0;
- if (obj)
- id = eventDispatcher->registerTimer(msec, Qt::CoarseTimer, obj);
+ start(msec, Qt::CoarseTimer, obj);
}
/*!
@@ -161,13 +144,7 @@ void QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj)
qWarning("QBasicTimer::start: Timers cannot be started from another thread");
return;
}
- if (id) {
- if (Q_LIKELY(eventDispatcher->unregisterTimer(id)))
- QAbstractEventDispatcherPrivate::releaseTimerId(id);
- else
- qWarning("QBasicTimer::start: Stopping previous timer failed. Possibly trying to stop from a different thread");
- }
- id = 0;
+ stop();
if (obj)
id = eventDispatcher->registerTimer(msec, timerType, obj);
}