Use explicit QThreadData::hasEventDispatcher() where possible
Change-Id: Ibce1a82dabb4e1381486211dbfb14eee9572e0ac Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
08f9dc1d32
commit
4266c54128
@ -101,7 +101,7 @@ QEventLoop::QEventLoop(QObject *parent)
|
||||
Q_D(QEventLoop);
|
||||
if (!QCoreApplication::instance() && QCoreApplicationPrivate::threadRequiresCoreApplication()) {
|
||||
qWarning("QEventLoop: Cannot be used without QApplication");
|
||||
} else if (!d->threadData->eventDispatcher.load()) {
|
||||
} else if (!d->threadData->hasEventDispatcher()) {
|
||||
QThreadPrivate::createEventDispatcher(d->threadData);
|
||||
}
|
||||
}
|
||||
@ -129,7 +129,7 @@ QEventLoop::~QEventLoop()
|
||||
bool QEventLoop::processEvents(ProcessEventsFlags flags)
|
||||
{
|
||||
Q_D(QEventLoop);
|
||||
if (!d->threadData->eventDispatcher.load())
|
||||
if (!d->threadData->hasEventDispatcher())
|
||||
return false;
|
||||
return d->threadData->eventDispatcher.load()->processEvents(flags);
|
||||
}
|
||||
@ -234,7 +234,7 @@ int QEventLoop::exec(ProcessEventsFlags flags)
|
||||
void QEventLoop::processEvents(ProcessEventsFlags flags, int maxTime)
|
||||
{
|
||||
Q_D(QEventLoop);
|
||||
if (!d->threadData->eventDispatcher.load())
|
||||
if (!d->threadData->hasEventDispatcher())
|
||||
return;
|
||||
|
||||
QElapsedTimer start;
|
||||
@ -263,7 +263,7 @@ void QEventLoop::processEvents(ProcessEventsFlags flags, int maxTime)
|
||||
void QEventLoop::exit(int returnCode)
|
||||
{
|
||||
Q_D(QEventLoop);
|
||||
if (!d->threadData->eventDispatcher.load())
|
||||
if (!d->threadData->hasEventDispatcher())
|
||||
return;
|
||||
|
||||
d->returnCode.store(returnCode);
|
||||
@ -292,7 +292,7 @@ bool QEventLoop::isRunning() const
|
||||
void QEventLoop::wakeUp()
|
||||
{
|
||||
Q_D(QEventLoop);
|
||||
if (!d->threadData->eventDispatcher.load())
|
||||
if (!d->threadData->hasEventDispatcher())
|
||||
return;
|
||||
d->threadData->eventDispatcher.load()->wakeUp();
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ QObjectPrivate::~QObjectPrivate()
|
||||
if (extraData && !extraData->runningTimers.isEmpty()) {
|
||||
if (Q_LIKELY(threadData->thread == QThread::currentThread())) {
|
||||
// unregister pending timers
|
||||
if (threadData->eventDispatcher.load())
|
||||
if (threadData->hasEventDispatcher())
|
||||
threadData->eventDispatcher.load()->unregisterTimers(q_ptr);
|
||||
|
||||
// release the timer ids back to the pool
|
||||
@ -1538,7 +1538,7 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData
|
||||
++eventsMoved;
|
||||
}
|
||||
}
|
||||
if (eventsMoved > 0 && targetData->eventDispatcher.load()) {
|
||||
if (eventsMoved > 0 && targetData->hasEventDispatcher()) {
|
||||
targetData->canWait = false;
|
||||
targetData->eventDispatcher.load()->wakeUp();
|
||||
}
|
||||
@ -1621,7 +1621,7 @@ int QObject::startTimer(int interval, Qt::TimerType timerType)
|
||||
qWarning("QObject::startTimer: Timers cannot have negative intervals");
|
||||
return 0;
|
||||
}
|
||||
if (Q_UNLIKELY(!d->threadData->eventDispatcher.load())) {
|
||||
if (Q_UNLIKELY(!d->threadData->hasEventDispatcher())) {
|
||||
qWarning("QObject::startTimer: Timers can only be used with threads started with QThread");
|
||||
return 0;
|
||||
}
|
||||
@ -1703,7 +1703,7 @@ void QObject::killTimer(int id)
|
||||
return;
|
||||
}
|
||||
|
||||
if (d->threadData->eventDispatcher.load())
|
||||
if (d->threadData->hasEventDispatcher())
|
||||
d->threadData->eventDispatcher.load()->unregisterTimer(id);
|
||||
|
||||
d->extraData->runningTimers.remove(at);
|
||||
|
@ -149,7 +149,7 @@ QSocketNotifier::QSocketNotifier(qintptr socket, Type type, QObject *parent)
|
||||
|
||||
if (socket < 0)
|
||||
qWarning("QSocketNotifier: Invalid socket specified");
|
||||
else if (!d->threadData->eventDispatcher.load())
|
||||
else if (!d->threadData->hasEventDispatcher())
|
||||
qWarning("QSocketNotifier: Can only be used with threads started with QThread");
|
||||
else
|
||||
d->threadData->eventDispatcher.load()->registerSocketNotifier(this);
|
||||
@ -234,7 +234,7 @@ void QSocketNotifier::setEnabled(bool enable)
|
||||
return;
|
||||
d->snenabled = enable;
|
||||
|
||||
if (!d->threadData->eventDispatcher.load()) // perhaps application/thread is shutting down
|
||||
if (!d->threadData->hasEventDispatcher()) // perhaps application/thread is shutting down
|
||||
return;
|
||||
if (Q_UNLIKELY(thread() != QThread::currentThread())) {
|
||||
qWarning("QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread");
|
||||
|
@ -352,7 +352,7 @@ void *QThreadPrivate::start(void *arg)
|
||||
data->quitNow = thr->d_func()->exited;
|
||||
}
|
||||
|
||||
if (data->eventDispatcher.load()) // custom event dispatcher set?
|
||||
if (data->hasEventDispatcher()) // custom event dispatcher set?
|
||||
data->eventDispatcher.load()->startingUp();
|
||||
else
|
||||
createEventDispatcher(data);
|
||||
|
@ -360,7 +360,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
|
||||
data->quitNow = thr->d_func()->exited;
|
||||
}
|
||||
|
||||
if (data->eventDispatcher.load()) // custom event dispatcher set?
|
||||
if (data->hasEventDispatcher()) // custom event dispatcher set?
|
||||
data->eventDispatcher.load()->startingUp();
|
||||
else
|
||||
createEventDispatcher(data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user