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