Migrate QBasicTimer from int to qint64

QBasicTimer::start() now accepts qint64 instead of int.

Change-Id: Iba3f394b6c20daf762f1add5a9eed22c8a67c802
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Konrad Kujawa 2022-08-25 15:39:22 +02:00
parent 89a703dcb8
commit da12a40b8b
6 changed files with 32 additions and 13 deletions

View File

@ -287,6 +287,18 @@ QT_WARNING_POP
#include "qbuffer.h" // inline removed API
#include "qbasictimer.h"
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 "qenvironmentvariables.h"
bool qputenv(const char *varName, const QByteArray &value)

View File

@ -26,8 +26,7 @@ public:
Qt::TimerType timerType;
inline TimerInfo(int id, int i, Qt::TimerType t)
: timerId(id), interval(i), timerType(t)
{ }
: timerId(id), interval(i), timerType(t) { }
};
explicit QAbstractEventDispatcher(QObject *parent = nullptr);

View File

@ -102,7 +102,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
\fn void QBasicTimer::start(int msec, QObject *object)
\fn void QBasicTimer::start(qint64 msec, QObject *object)
Starts (or restarts) the timer with a \a msec milliseconds timeout. The
timer will be a Qt::CoarseTimer. See Qt::TimerType for information on the
@ -110,9 +110,12 @@ QT_BEGIN_NAMESPACE
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(int msec, QObject *obj)
void QBasicTimer::start(qint64 msec, QObject *obj)
{
start(msec, Qt::CoarseTimer, obj);
}
@ -126,9 +129,12 @@ void QBasicTimer::start(int msec, QObject *obj)
\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(int msec, Qt::TimerType timerType, QObject *obj)
void QBasicTimer::start(qint64 msec, Qt::TimerType timerType, QObject *obj)
{
QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
if (Q_UNLIKELY(msec < 0)) {

View File

@ -31,9 +31,12 @@ public:
bool isActive() const noexcept { return id != 0; }
int timerId() const noexcept { return id; }
#if QT_CORE_REMOVED_SINCE(6, 5)
void start(int msec, QObject *obj);
void start(int msec, Qt::TimerType timerType, QObject *obj);
#endif
void start(qint64 msec, QObject *obj);
void start(qint64 msec, Qt::TimerType timerType, QObject *obj);
void stop();
};
Q_DECLARE_TYPEINFO(QBasicTimer, Q_RELOCATABLE_TYPE);

View File

@ -380,18 +380,17 @@ bool QTimerInfoList::timerWait(timespec &tm)
}
/*
Returns the timer's remaining time in milliseconds with the given timerId, or
null if there is nothing left. If the timer id is not found in the list, the
returned value will be -1. If the timer is overdue, the returned value will be 0.
Returns the timer's remaining time in milliseconds with the given timerId.
If the timer id is not found in the list, the returned value will be -1.
If the timer is overdue, the returned value will be 0.
*/
int QTimerInfoList::timerRemainingTime(int timerId)
qint64 QTimerInfoList::timerRemainingTime(int timerId)
{
timespec currentTime = updateCurrentTime();
repairTimersIfNeeded();
timespec tm = {0, 0};
for (int i = 0; i < count(); ++i) {
QTimerInfo *t = at(i);
for (const auto *t : *this) {
if (t->id == timerId) {
if (currentTime < t->timeout) {
// time to wait

View File

@ -68,7 +68,7 @@ public:
bool timerWait(timespec &);
void timerInsert(QTimerInfo *);
int timerRemainingTime(int timerId);
qint64 timerRemainingTime(int timerId);
void registerTimer(int timerId, qint64 interval, Qt::TimerType timerType, QObject *object);
bool unregisterTimer(int timerId);