From af383319f67248498d27071ad347a7fb90e32d93 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 18 Feb 2024 19:22:07 -0800 Subject: [PATCH] QSingleShotTimer: use the Duration alias from the event dispatcher Just so we don't accidentally use different precisions. Amends commit bfc7535a10f7a6e3723f354b41f08a0fe1d18719. Change-Id: I83dda2d36c904517b3c0fffd17b5258e88dd194e Reviewed-by: Ahmad Samir --- src/corelib/kernel/qsingleshottimer_p.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/corelib/kernel/qsingleshottimer_p.h b/src/corelib/kernel/qsingleshottimer_p.h index 3ae207fcd4..d7e33c5221 100644 --- a/src/corelib/kernel/qsingleshottimer_p.h +++ b/src/corelib/kernel/qsingleshottimer_p.h @@ -31,13 +31,16 @@ class QSingleShotTimer : public QObject Qt::TimerId timerId = Qt::TimerId::Invalid; public: + // use the same duration type + using Duration = QAbstractEventDispatcher::Duration; + inline ~QSingleShotTimer(); - inline QSingleShotTimer(std::chrono::nanoseconds interval, Qt::TimerType timerType, + inline QSingleShotTimer(Duration interval, Qt::TimerType timerType, const QObject *r, const char *member); - inline QSingleShotTimer(std::chrono::nanoseconds interval, Qt::TimerType timerType, + inline QSingleShotTimer(Duration interval, Qt::TimerType timerType, const QObject *r, QtPrivate::QSlotObjectBase *slotObj); - inline void startTimerForReceiver(std::chrono::nanoseconds interval, Qt::TimerType timerType, + inline void startTimerForReceiver(Duration interval, Qt::TimerType timerType, const QObject *receiver); Q_SIGNALS: @@ -47,7 +50,7 @@ private: inline void timerEvent(QTimerEvent *) override; }; -QSingleShotTimer::QSingleShotTimer(std::chrono::nanoseconds interval, Qt::TimerType timerType, +QSingleShotTimer::QSingleShotTimer(Duration interval, Qt::TimerType timerType, const QObject *r, const char *member) : QObject(QAbstractEventDispatcher::instance()) { @@ -55,7 +58,7 @@ QSingleShotTimer::QSingleShotTimer(std::chrono::nanoseconds interval, Qt::TimerT startTimerForReceiver(interval, timerType, r); } -QSingleShotTimer::QSingleShotTimer(std::chrono::nanoseconds interval, Qt::TimerType timerType, +QSingleShotTimer::QSingleShotTimer(Duration interval, Qt::TimerType timerType, const QObject *r, QtPrivate::QSlotObjectBase *slotObj) : QObject(QAbstractEventDispatcher::instance()) { @@ -78,8 +81,8 @@ QSingleShotTimer::~QSingleShotTimer() the same thread as where it will be handled, so that it fires reliably even if the thread that set up the timer is busy. */ -void QSingleShotTimer::startTimerForReceiver(std::chrono::nanoseconds interval, - Qt::TimerType timerType, const QObject *receiver) +void QSingleShotTimer::startTimerForReceiver(Duration interval, Qt::TimerType timerType, + const QObject *receiver) { if (receiver && receiver->thread() != thread()) { // Avoid leaking the QSingleShotTimer instance in case the application exits before the