Change QTimerInfo (UNIX) to keep the interval in milliseconds.
The API passes the interval as an int, there's no reason to convert it to a timeval struct. This also prepares for changing the UNIX timer code to support the different timer types. Author: Thiago Macieira <thiago.macieira@nokia.com> Change-Id: Ie3cc1ae8f1be6a9ad3f1766051642cbf3e614418 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
2bbf9befd8
commit
6fc9820d2a
@ -185,6 +185,19 @@ void QTimerInfoList::timerRepair(const timeval &diff)
|
||||
}
|
||||
}
|
||||
|
||||
inline timeval &operator+=(timeval &t1, int ms)
|
||||
{
|
||||
t1.tv_sec += ms / 1000;
|
||||
t1.tv_usec += ms % 1000 * 1000;
|
||||
return normalizedTimeval(t1);
|
||||
}
|
||||
|
||||
inline timeval operator+(const timeval &t1, int ms)
|
||||
{
|
||||
timeval t2 = t1;
|
||||
return t2 += ms;
|
||||
}
|
||||
|
||||
static timeval roundToMillisecond(timeval val)
|
||||
{
|
||||
// always round up
|
||||
@ -232,9 +245,8 @@ void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType time
|
||||
{
|
||||
QTimerInfo *t = new QTimerInfo;
|
||||
t->id = timerId;
|
||||
t->interval = interval;
|
||||
t->timerType = timerType;
|
||||
t->interval.tv_sec = interval / 1000;
|
||||
t->interval.tv_usec = (interval % 1000) * 1000;
|
||||
t->timeout = updateCurrentTime() + t->interval;
|
||||
t->obj = object;
|
||||
t->activateRef = 0;
|
||||
@ -299,7 +311,7 @@ QList<QAbstractEventDispatcher::TimerInfo> QTimerInfoList::registeredTimers(QObj
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
register const QTimerInfo * const t = at(i);
|
||||
if (t->obj == object)
|
||||
list << QAbstractEventDispatcher::TimerInfo(t->id, t->interval.tv_sec * 1000 + t->interval.tv_usec / 1000, t->timerType);
|
||||
list << QAbstractEventDispatcher::TimerInfo(t->id, t->interval, t->timerType);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -355,7 +367,7 @@ int QTimerInfoList::activateTimers()
|
||||
|
||||
// reinsert timer
|
||||
timerInsert(currentTimerInfo);
|
||||
if (currentTimerInfo->interval.tv_usec > 0 || currentTimerInfo->interval.tv_sec > 0)
|
||||
if (currentTimerInfo->interval > 0)
|
||||
n_act++;
|
||||
|
||||
if (!currentTimerInfo->activateRef) {
|
||||
|
@ -62,8 +62,8 @@ QT_BEGIN_NAMESPACE
|
||||
// internal timer info
|
||||
struct QTimerInfo {
|
||||
int id; // - timer identifier
|
||||
int interval; // - timer interval in milliseconds
|
||||
Qt::TimerType timerType; // - timer type
|
||||
timeval interval; // - timer interval
|
||||
timeval timeout; // - when to sent event
|
||||
QObject *obj; // - object to receive event
|
||||
QTimerInfo **activateRef; // - ref from activateTimers
|
||||
|
Loading…
Reference in New Issue
Block a user