Make QThreadPrivate::createEventDispatcher do exactly what it says
Leaving the logic of starting up the event dispatcher to the call site, unified both the case of a custom event dispatcher and the default event dispatcher. The data argument is left in due to the static nature of the function. Change-Id: Ia2020e39ccc67cd5a583d4e614dd978b2ec44dba Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
fe5edcee60
commit
54d57cbd6f
@ -102,7 +102,9 @@ QEventLoop::QEventLoop(QObject *parent)
|
|||||||
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->hasEventDispatcher()) {
|
} else if (!d->threadData->hasEventDispatcher()) {
|
||||||
QThreadPrivate::createEventDispatcher(d->threadData);
|
QAbstractEventDispatcher *eventDispatcher = QThreadPrivate::createEventDispatcher(d->threadData);
|
||||||
|
d->threadData->eventDispatcher.storeRelease(eventDispatcher);
|
||||||
|
eventDispatcher->startingUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ public:
|
|||||||
#endif // Q_OS_WIN
|
#endif // Q_OS_WIN
|
||||||
QThreadData *data;
|
QThreadData *data;
|
||||||
|
|
||||||
static void createEventDispatcher(QThreadData *data);
|
static QAbstractEventDispatcher *createEventDispatcher(QThreadData *data);
|
||||||
|
|
||||||
void ref()
|
void ref()
|
||||||
{
|
{
|
||||||
@ -222,7 +222,7 @@ public:
|
|||||||
|
|
||||||
static void setCurrentThread(QThread*) {}
|
static void setCurrentThread(QThread*) {}
|
||||||
static QThread *threadForId(int) { return QThread::currentThread(); }
|
static QThread *threadForId(int) { return QThread::currentThread(); }
|
||||||
static void createEventDispatcher(QThreadData *data);
|
static QAbstractEventDispatcher *createEventDispatcher(QThreadData *data);
|
||||||
|
|
||||||
void ref() {}
|
void ref() {}
|
||||||
void deref() {}
|
void deref() {}
|
||||||
|
@ -285,27 +285,26 @@ typedef void*(*QtThreadCallback)(void*);
|
|||||||
|
|
||||||
#endif // QT_NO_THREAD
|
#endif // QT_NO_THREAD
|
||||||
|
|
||||||
void QThreadPrivate::createEventDispatcher(QThreadData *data)
|
QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *data)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(data);
|
||||||
#if defined(Q_OS_DARWIN)
|
#if defined(Q_OS_DARWIN)
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
int value = qEnvironmentVariableIntValue("QT_EVENT_DISPATCHER_CORE_FOUNDATION", &ok);
|
int value = qEnvironmentVariableIntValue("QT_EVENT_DISPATCHER_CORE_FOUNDATION", &ok);
|
||||||
if (ok && value > 0)
|
if (ok && value > 0)
|
||||||
data->eventDispatcher.storeRelease(new QEventDispatcherCoreFoundation);
|
return new QEventDispatcherCoreFoundation;
|
||||||
else
|
else
|
||||||
data->eventDispatcher.storeRelease(new QEventDispatcherUNIX);
|
return new QEventDispatcherUNIX;
|
||||||
#elif !defined(QT_NO_GLIB)
|
#elif !defined(QT_NO_GLIB)
|
||||||
if (qEnvironmentVariableIsEmpty("QT_NO_GLIB")
|
if (qEnvironmentVariableIsEmpty("QT_NO_GLIB")
|
||||||
&& qEnvironmentVariableIsEmpty("QT_NO_THREADED_GLIB")
|
&& qEnvironmentVariableIsEmpty("QT_NO_THREADED_GLIB")
|
||||||
&& QEventDispatcherGlib::versionSupported())
|
&& QEventDispatcherGlib::versionSupported())
|
||||||
data->eventDispatcher.storeRelease(new QEventDispatcherGlib);
|
return new QEventDispatcherGlib;
|
||||||
else
|
else
|
||||||
data->eventDispatcher.storeRelease(new QEventDispatcherUNIX);
|
return new QEventDispatcherUNIX;
|
||||||
#else
|
#else
|
||||||
data->eventDispatcher.storeRelease(new QEventDispatcherUNIX);
|
return new QEventDispatcherUNIX;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
data->eventDispatcher.load()->startingUp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_THREAD
|
#ifndef QT_NO_THREAD
|
||||||
@ -352,10 +351,13 @@ void *QThreadPrivate::start(void *arg)
|
|||||||
data->quitNow = thr->d_func()->exited;
|
data->quitNow = thr->d_func()->exited;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->hasEventDispatcher()) // custom event dispatcher set?
|
QAbstractEventDispatcher *eventDispatcher = data->eventDispatcher.load();
|
||||||
data->eventDispatcher.load()->startingUp();
|
if (!eventDispatcher) {
|
||||||
else
|
eventDispatcher = createEventDispatcher(data);
|
||||||
createEventDispatcher(data);
|
data->eventDispatcher.storeRelease(eventDispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
eventDispatcher->startingUp();
|
||||||
|
|
||||||
#if (defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_QNX))
|
#if (defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_QNX))
|
||||||
{
|
{
|
||||||
|
@ -331,15 +331,14 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName)
|
|||||||
|
|
||||||
#endif // QT_NO_THREAD
|
#endif // QT_NO_THREAD
|
||||||
|
|
||||||
void QThreadPrivate::createEventDispatcher(QThreadData *data)
|
QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *data)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(data);
|
||||||
#ifndef Q_OS_WINRT
|
#ifndef Q_OS_WINRT
|
||||||
QEventDispatcherWin32 *theEventDispatcher = new QEventDispatcherWin32;
|
return new QEventDispatcherWin32;
|
||||||
#else
|
#else
|
||||||
QEventDispatcherWinRT *theEventDispatcher = new QEventDispatcherWinRT;
|
return new QEventDispatcherWinRT;
|
||||||
#endif
|
#endif
|
||||||
data->eventDispatcher.storeRelease(theEventDispatcher);
|
|
||||||
theEventDispatcher->startingUp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_THREAD
|
#ifndef QT_NO_THREAD
|
||||||
@ -360,10 +359,13 @@ 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->hasEventDispatcher()) // custom event dispatcher set?
|
QAbstractEventDispatcher *eventDispatcher = data->eventDispatcher.load();
|
||||||
data->eventDispatcher.load()->startingUp();
|
if (!eventDispatcher) {
|
||||||
else
|
eventDispatcher = createEventDispatcher(data);
|
||||||
createEventDispatcher(data);
|
data->eventDispatcher.storeRelease(eventDispatcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
eventDispatcher->startingUp();
|
||||||
|
|
||||||
#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
|
#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
|
||||||
// sets the name of the current thread.
|
// sets the name of the current thread.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user