diff options
| author | Ahmad Samir <a.samirh78@gmail.com> | 2023-03-06 15:02:44 +0200 |
|---|---|---|
| committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-03-11 12:40:04 +0200 |
| commit | e426a4e3fad376aecdfb1e308b22eba9002aacf7 (patch) | |
| tree | bc1bc63edd536037176999e15cf2d93dd590fddc /src/corelib/kernel/qtimer.cpp | |
| parent | 957ed5e71eef1f9d75f6bdb9dcaebd4d16a3b1b1 (diff) | |
QObject: implement startTimer(int) in terms of startTimer(chrono)
I.e. use chrono first, this means the API isn't limited by the size of
int, but by the size of whatever chrono::milliseconds uses (typically
int64_t), and chrono units are much more readable as well.
Task-number: QTBUG-110059
Change-Id: Ie7f2d90864782361a89866693011803be6f8545e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qtimer.cpp')
| -rw-r--r-- | src/corelib/kernel/qtimer.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp index b2b9c5f2008..73f0fb8fee3 100644 --- a/src/corelib/kernel/qtimer.cpp +++ b/src/corelib/kernel/qtimer.cpp @@ -187,7 +187,7 @@ void QTimer::start() Q_D(QTimer); if (d->id != QTimerPrivate::INV_TIMER) // stop running timer stop(); - d->id = QObject::startTimer(d->inter, d->type); + d->id = QObject::startTimer(std::chrono::milliseconds{d->inter}, d->type); d->isActiveData.notify(); } @@ -266,14 +266,14 @@ protected: QSingleShotTimer::QSingleShotTimer(int msec, Qt::TimerType timerType, const QObject *r, const char *member) : QObject(QAbstractEventDispatcher::instance()), hasValidReceiver(true), slotObj(nullptr) { - timerId = startTimer(msec, timerType); + timerId = startTimer(std::chrono::milliseconds{msec}, timerType); connect(this, SIGNAL(timeout()), r, member); } QSingleShotTimer::QSingleShotTimer(int msec, Qt::TimerType timerType, const QObject *r, QtPrivate::QSlotObjectBase *slotObj) : QObject(QAbstractEventDispatcher::instance()), hasValidReceiver(r), receiver(r), slotObj(slotObj) { - timerId = startTimer(msec, timerType); + timerId = startTimer(std::chrono::milliseconds{msec}, timerType); if (r && thread() != r->thread()) { // Avoid leaking the QSingleShotTimer instance in case the application exits before the timer fires connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &QObject::deleteLater); @@ -708,7 +708,7 @@ void QTimer::setInterval(int msec) d->inter.setValue(msec); if (d->id != QTimerPrivate::INV_TIMER) { // create new timer QObject::killTimer(d->id); // restart timer - d->id = QObject::startTimer(msec, d->type); + d->id = QObject::startTimer(std::chrono::milliseconds{msec}, d->type); // No need to call markDirty() for d->isActiveData here, // as timer state actually does not change } |
