diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-03-01 08:23:55 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-03-02 03:56:33 +0100 |
commit | 5573e2d6ac09ff8b8f23edca93f601ff7679fa3c (patch) | |
tree | 8156de12bfb30d36c97e730d129df1cb0b256743 /src/corelib/kernel/qbasictimer.cpp | |
parent | 38664dabedb9906ee576b717df174e5a503aea09 (diff) |
QBasicTimer: replace new qint64 overloads with chrono ones
Found in API review.
As per "chrono first" initiative[1], implement the int overload via the
chrono one, not vice versa
[1] https://lists.qt-project.org/pipermail/development/2023-January/043563.html
Pick-to: 6.5
Change-Id: I65fe7039ad8ae5f9eb21d9c59a46b9c5c152fac3
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/kernel/qbasictimer.cpp')
-rw-r--r-- | src/corelib/kernel/qbasictimer.cpp | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/corelib/kernel/qbasictimer.cpp b/src/corelib/kernel/qbasictimer.cpp index 7d762047c1..b843ec1ecf 100644 --- a/src/corelib/kernel/qbasictimer.cpp +++ b/src/corelib/kernel/qbasictimer.cpp @@ -102,42 +102,50 @@ QT_BEGIN_NAMESPACE */ /*! - \fn void QBasicTimer::start(qint64 msec, QObject *object) + \fn void QBasicTimer::start(int msec, QObject *object) - Starts (or restarts) the timer with a \a msec milliseconds timeout. The + \obsolete Use chrono overload instead. +*/ + +/*! + \since 6.5 + + Starts (or restarts) the timer with a \a duration timeout. The timer will be a Qt::CoarseTimer. See Qt::TimerType for information on the different timer types. The given \a object will receive timer events. - \note In Qt versions prior to 6.5, \a msec was \c{int}, not - \c{qint64}. - \sa stop(), isActive(), QObject::timerEvent(), Qt::CoarseTimer */ -void QBasicTimer::start(qint64 msec, QObject *obj) +void QBasicTimer::start(std::chrono::milliseconds duration, QObject *object) { - start(msec, Qt::CoarseTimer, obj); + start(duration, Qt::CoarseTimer, object); } /*! + \fn QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj) \overload + \obsolete - Starts (or restarts) the timer with a \a msec milliseconds timeout and the + Use chrono overload instead. +*/ + +/*! + \since 6.5 + + Starts (or restarts) the timer with a \a duration timeout and the given \a timerType. See Qt::TimerType for information on the different timer types. \a obj will receive timer events. - \note In Qt versions prior to 6.5, \a msec was \c{int}, not - \c{qint64}. - \sa stop(), isActive(), QObject::timerEvent(), Qt::TimerType */ -void QBasicTimer::start(qint64 msec, Qt::TimerType timerType, QObject *obj) +void QBasicTimer::start(std::chrono::milliseconds duration, Qt::TimerType timerType, QObject *obj) { QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(); - if (Q_UNLIKELY(msec < 0)) { + if (Q_UNLIKELY(duration.count() < 0)) { qWarning("QBasicTimer::start: Timers cannot have negative timeouts"); return; } @@ -151,7 +159,7 @@ void QBasicTimer::start(qint64 msec, Qt::TimerType timerType, QObject *obj) } stop(); if (obj) - id = eventDispatcher->registerTimer(msec, timerType, obj); + id = eventDispatcher->registerTimer(duration.count(), timerType, obj); } /*! |