Share event dispatcher creation between QThreadPrivate and QCoreApplication
A step towards having the application do its event dispatching though the thread data's dispatcher, like QEventLoop, instead of keeping two references to the same dispatcher, one in QCoreApplicationPrivate and one in QThreadData. Change-Id: I7b215e7e99869d25638ec67f0666f632a508cc0f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
ea21b36836
commit
6c4f5ecef0
@ -538,29 +538,10 @@ void QCoreApplicationPrivate::cleanupThreadData()
|
||||
void QCoreApplicationPrivate::createEventDispatcher()
|
||||
{
|
||||
Q_Q(QCoreApplication);
|
||||
#if defined(Q_OS_UNIX)
|
||||
# if defined(Q_OS_DARWIN)
|
||||
bool ok = false;
|
||||
int value = qEnvironmentVariableIntValue("QT_EVENT_DISPATCHER_CORE_FOUNDATION", &ok);
|
||||
if (ok && value > 0)
|
||||
eventDispatcher = new QEventDispatcherCoreFoundation(q);
|
||||
else
|
||||
eventDispatcher = new QEventDispatcherUNIX(q);
|
||||
# elif !defined(QT_NO_GLIB)
|
||||
if (qEnvironmentVariableIsEmpty("QT_NO_GLIB") && QEventDispatcherGlib::versionSupported())
|
||||
eventDispatcher = new QEventDispatcherGlib(q);
|
||||
else
|
||||
eventDispatcher = new QEventDispatcherUNIX(q);
|
||||
# else
|
||||
eventDispatcher = new QEventDispatcherUNIX(q);
|
||||
# endif
|
||||
#elif defined(Q_OS_WINRT)
|
||||
eventDispatcher = new QEventDispatcherWinRT(q);
|
||||
#elif defined(Q_OS_WIN)
|
||||
eventDispatcher = new QEventDispatcherWin32(q);
|
||||
#else
|
||||
# error "QEventDispatcher not yet ported to this platform"
|
||||
#endif
|
||||
QThreadData *data = QThreadData::current();
|
||||
Q_ASSERT(!data->hasEventDispatcher());
|
||||
eventDispatcher = QThreadPrivate::createEventDispatcher(data);
|
||||
eventDispatcher->setParent(q);
|
||||
}
|
||||
|
||||
void QCoreApplicationPrivate::eventDispatcherReady()
|
||||
|
@ -296,8 +296,9 @@ QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *dat
|
||||
else
|
||||
return new QEventDispatcherUNIX;
|
||||
#elif !defined(QT_NO_GLIB)
|
||||
const bool isQtMainThread = data->thread == QCoreApplicationPrivate::mainThread();
|
||||
if (qEnvironmentVariableIsEmpty("QT_NO_GLIB")
|
||||
&& qEnvironmentVariableIsEmpty("QT_NO_THREADED_GLIB")
|
||||
&& (isQtMainThread || qEnvironmentVariableIsEmpty("QT_NO_THREADED_GLIB"))
|
||||
&& QEventDispatcherGlib::versionSupported())
|
||||
return new QEventDispatcherGlib;
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user