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>
This commit is contained in:
parent
38664dabed
commit
5573e2d6ac
@ -270,17 +270,7 @@ QT_WARNING_POP
|
|||||||
|
|
||||||
#if QT_CORE_REMOVED_SINCE(6, 5)
|
#if QT_CORE_REMOVED_SINCE(6, 5)
|
||||||
|
|
||||||
#include "qbasictimer.h"
|
#include "qbasictimer.h" // inlined API
|
||||||
|
|
||||||
void QBasicTimer::start(int msec, QObject *obj)
|
|
||||||
{
|
|
||||||
start(qint64(msec), obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj)
|
|
||||||
{
|
|
||||||
start(qint64(msec), timerType, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "qbuffer.h" // inline removed API
|
#include "qbuffer.h" // inline removed API
|
||||||
|
|
||||||
|
@ -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
|
timer will be a Qt::CoarseTimer. See Qt::TimerType for information on the
|
||||||
different timer types.
|
different timer types.
|
||||||
|
|
||||||
The given \a object will receive timer events.
|
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
|
\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
|
\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
|
given \a timerType. See Qt::TimerType for information on the different
|
||||||
timer types.
|
timer types.
|
||||||
|
|
||||||
\a obj will receive timer events.
|
\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
|
\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();
|
QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
|
||||||
if (Q_UNLIKELY(msec < 0)) {
|
if (Q_UNLIKELY(duration.count() < 0)) {
|
||||||
qWarning("QBasicTimer::start: Timers cannot have negative timeouts");
|
qWarning("QBasicTimer::start: Timers cannot have negative timeouts");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -151,7 +159,7 @@ void QBasicTimer::start(qint64 msec, Qt::TimerType timerType, QObject *obj)
|
|||||||
}
|
}
|
||||||
stop();
|
stop();
|
||||||
if (obj)
|
if (obj)
|
||||||
id = eventDispatcher->registerTimer(msec, timerType, obj);
|
id = eventDispatcher->registerTimer(duration.count(), timerType, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
#include <QtCore/qnamespace.h>
|
#include <QtCore/qnamespace.h>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
@ -31,16 +33,28 @@ public:
|
|||||||
|
|
||||||
bool isActive() const noexcept { return id != 0; }
|
bool isActive() const noexcept { return id != 0; }
|
||||||
int timerId() const noexcept { return id; }
|
int timerId() const noexcept { return id; }
|
||||||
#if QT_CORE_REMOVED_SINCE(6, 5)
|
QT_CORE_INLINE_SINCE(6, 5)
|
||||||
void start(int msec, QObject *obj);
|
void start(int msec, QObject *obj);
|
||||||
|
QT_CORE_INLINE_SINCE(6, 5)
|
||||||
void start(int msec, Qt::TimerType timerType, QObject *obj);
|
void start(int msec, Qt::TimerType timerType, QObject *obj);
|
||||||
#endif
|
void start(std::chrono::milliseconds duration, QObject *obj);
|
||||||
void start(qint64 msec, QObject *obj);
|
void start(std::chrono::milliseconds duration, Qt::TimerType timerType, QObject *obj);
|
||||||
void start(qint64 msec, Qt::TimerType timerType, QObject *obj);
|
|
||||||
void stop();
|
void stop();
|
||||||
};
|
};
|
||||||
Q_DECLARE_TYPEINFO(QBasicTimer, Q_RELOCATABLE_TYPE);
|
Q_DECLARE_TYPEINFO(QBasicTimer, Q_RELOCATABLE_TYPE);
|
||||||
|
|
||||||
|
#if QT_CORE_INLINE_IMPL_SINCE(6, 5)
|
||||||
|
void QBasicTimer::start(int msec, QObject *obj)
|
||||||
|
{
|
||||||
|
start(std::chrono::milliseconds{msec}, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QBasicTimer::start(int msec, Qt::TimerType t, QObject *obj)
|
||||||
|
{
|
||||||
|
start(std::chrono::milliseconds{msec}, t, obj);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
inline void swap(QBasicTimer &lhs, QBasicTimer &rhs) noexcept { lhs.swap(rhs); }
|
inline void swap(QBasicTimer &lhs, QBasicTimer &rhs) noexcept { lhs.swap(rhs); }
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user