summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.cpp
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2011-12-21 11:33:33 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-02 10:44:00 +0100
commit2bbf9befd8879dcfca9f48ac9ac13daf40f48847 (patch)
tree42457f54a2a25cf2a8de6a9292c60b7513339c4a /src/corelib/kernel/qobject.cpp
parentef60ed1c9dbc87d9f8401036cc254a9c45cd8ca8 (diff)
Add Qt::TimerType argument to QAbstractEventDispatcher::registerTimer()
... and deprecate the old registerTimer() functions. The new pure- virtual registerTimer() breaks source-compatibility. Subclasses cannot be instantiated anymore, since the pure virtual function signature has changed. QAbstractEventDispatcher::TimerInfo is no longer a QPair. It is now a struct with timerId, interval, and timerType members. This is a source incompatibility that should only affect subclasses of QAbstractEventDispatcher, which will need to pass 3 arguments to the TimerInfo constructor instead of 2. If the subclass used QPair<int,int> instead of the TimerInfo typedef, the QPair<int,int> declarations will need to be replaced with TimerInfo. Call the new registerTimer() function with the type from QObject::startTimer(). Change all subclasses of QAbstractEventDispatcher to reimplement the new virtual function. The type argument is unused at the momemnt, except to ensure that registeredTimers() returns the type each timer was registered with. Implementations for the various dispatchers will be done in separate commits. Author: Thiago Macieira <thiago.macieira@nokia.com> Change-Id: Ia22697e0ab0847810c5d162ef473e0e5a17a904b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qobject.cpp')
-rw-r--r--src/corelib/kernel/qobject.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 8db8aceced..db2ab4218d 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1017,7 +1017,7 @@ bool QObject::event(QEvent *e)
QThreadData *threadData = d->threadData;
QAbstractEventDispatcher *eventDispatcher = threadData->eventDispatcher;
if (eventDispatcher) {
- QList<QPair<int, int> > timers = eventDispatcher->registeredTimers(this);
+ QList<QAbstractEventDispatcher::TimerInfo> timers = eventDispatcher->registeredTimers(this);
if (!timers.isEmpty()) {
// set inThreadChangeEvent to true to tell the dispatcher not to release out timer ids
// back to the pool (since the timer ids are moving to a new thread).
@@ -1025,7 +1025,7 @@ bool QObject::event(QEvent *e)
eventDispatcher->unregisterTimers(this);
d->inThreadChangeEvent = false;
QMetaObject::invokeMethod(this, "_q_reregisterTimers", Qt::QueuedConnection,
- Q_ARG(void*, (new QList<QPair<int, int> >(timers))));
+ Q_ARG(void*, (new QList<QAbstractEventDispatcher::TimerInfo>(timers))));
}
}
break;
@@ -1322,11 +1322,11 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData
void QObjectPrivate::_q_reregisterTimers(void *pointer)
{
Q_Q(QObject);
- QList<QPair<int, int> > *timerList = reinterpret_cast<QList<QPair<int, int> > *>(pointer);
+ QList<QAbstractEventDispatcher::TimerInfo> *timerList = reinterpret_cast<QList<QAbstractEventDispatcher::TimerInfo> *>(pointer);
QAbstractEventDispatcher *eventDispatcher = threadData->eventDispatcher;
for (int i = 0; i < timerList->size(); ++i) {
- const QPair<int, int> &pair = timerList->at(i);
- eventDispatcher->registerTimer(pair.first, pair.second, q);
+ const QAbstractEventDispatcher::TimerInfo &ti = timerList->at(i);
+ eventDispatcher->registerTimer(ti.timerId, ti.interval, ti.timerType, q);
}
delete timerList;
}
@@ -1388,7 +1388,7 @@ int QObject::startTimer(int interval, Qt::TimerType timerType)
qWarning("QObject::startTimer: QTimer can only be used with threads started with QThread");
return 0;
}
- return d->threadData->eventDispatcher->registerTimer(interval, this);
+ return d->threadData->eventDispatcher->registerTimer(interval, timerType, this);
}
/*!