diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-02-13 17:11:50 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-02-15 14:00:21 +0000 |
commit | 6c4f5ecef0c9bc8bfb31ef4099d53ba02f0611aa (patch) | |
tree | 0a7d94638f03ad025e93da0cf2faa50e0224029f /src | |
parent | ea21b36836abd6c2bb6d139c9d4b8149acdc4785 (diff) | |
download | qtbase-6c4f5ecef0c9bc8bfb31ef4099d53ba02f0611aa.tar.gz |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 27 | ||||
-rw-r--r-- | src/corelib/thread/qthread_unix.cpp | 3 |
2 files changed, 6 insertions, 24 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index ef431baca6..4e32f90964 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -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() diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 2c815b870a..6248842d78 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -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 |