diff options
author | Morten Johan Sørvig <morten.sorvig@theqtcompany.com> | 2015-07-01 09:57:33 +0200 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> | 2015-11-19 16:04:56 +0000 |
commit | 97c8f6aa9c774aa0aac8948dd619e93944ec104a (patch) | |
tree | 662a098204b249fd2730f319b47e15bebbac0ffc /src/corelib/thread | |
parent | ff4d8906f6e42feec1e55de7aa7e3bea3825cdee (diff) |
OS X: Add opt-in for CoreFoundation event dispatcher
Opt-in by setting
QT_EVENT_DISPATCHER_CORE_FOUNDATION=1
This will make QCoreApplication and QThread create
a QEventDispatcherCoreFoundation instead of a
QEventDispatcherUNIX.
With this change we can now support calling native API
that requires a running Core Foundation event loop
on the QCoreApplication main thread and secondary
threads. Previously this was only supported on the
QGuiApplication main thread.
Rewrite the #ifdef event dispatcher logic slightly:
both OSX and GLIB now gets an "else" branch for the
UNIX event dispatcher, instead of the current "dangling
else" pattern which only works for one #ifdef case.
Change-Id: If853567fa097fe007502b0804c2307a989719866
Task-number: QTBUG-46625
Task-number: QTBUG-48758
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qthread_unix.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index c340915d35..af4ce7c59e 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -36,9 +36,13 @@ #include "qplatformdefs.h" #include <private/qcoreapplication_p.h> +#include <private/qcore_unix_p.h> #if defined(Q_OS_BLACKBERRY) # include <private/qeventdispatcher_blackberry_p.h> +#elif defined(Q_OS_OSX) +# include <private/qeventdispatcher_cf_p.h> +# include <private/qeventdispatcher_unix_p.h> #else # if !defined(QT_NO_GLIB) # include "../kernel/qeventdispatcher_glib_p.h" @@ -248,14 +252,21 @@ void QThreadPrivate::createEventDispatcher(QThreadData *data) { #if defined(Q_OS_BLACKBERRY) data->eventDispatcher.storeRelease(new QEventDispatcherBlackberry); -#else -#if !defined(QT_NO_GLIB) +# elif defined(Q_OS_OSX) + bool ok = false; + int value = qEnvironmentVariableIntValue("QT_EVENT_DISPATCHER_CORE_FOUNDATION", &ok); + if (ok && value > 0) + data->eventDispatcher.storeRelease(new QEventDispatcherCoreFoundation); + else + data->eventDispatcher.storeRelease(new QEventDispatcherUNIX); +# elif !defined(QT_NO_GLIB) if (qEnvironmentVariableIsEmpty("QT_NO_GLIB") && qEnvironmentVariableIsEmpty("QT_NO_THREADED_GLIB") && QEventDispatcherGlib::versionSupported()) data->eventDispatcher.storeRelease(new QEventDispatcherGlib); else -#endif + data->eventDispatcher.storeRelease(new QEventDispatcherUNIX); +#else data->eventDispatcher.storeRelease(new QEventDispatcherUNIX); #endif |