summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qeventdispatcher_cf_p.h
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2018-07-04 00:20:37 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2018-08-09 07:24:15 +0000
commita09c8b0ee6ddd13251ee1335ede73fd66e007a35 (patch)
tree9c7cb2af31892edc16b696c86bde948152b8cb2f /src/corelib/kernel/qeventdispatcher_cf_p.h
parent489ae6db3c1d4c78b60f67d1c64e6bdb820560eb (diff)
Make QEventDispatcherCoreFoundaton work on secondary threads
We were using CFRunLoopGetMain() everywhere. Get the correct run loop using CFRunLoopGetCurrent() during initialization, and store it. Event dispatcher initialization must now be delayed until after the constructor has run, since event dispatchers may be created on the main thread and then moved to the target thread. Initialize on first call to processEvents() where the current thread will be the correct thread. Use the stored m_runLoop instead of CFRunLoopGetMain(). This is required for wakeUp() and interrupt() which may be called from another thread. Change-Id: I6fffcfd4394899c4a12f241c42781979aaf99d5e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/corelib/kernel/qeventdispatcher_cf_p.h')
-rw-r--r--src/corelib/kernel/qeventdispatcher_cf_p.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_cf_p.h b/src/corelib/kernel/qeventdispatcher_cf_p.h
index ac9170da89..26191d520c 100644
--- a/src/corelib/kernel/qeventdispatcher_cf_p.h
+++ b/src/corelib/kernel/qeventdispatcher_cf_p.h
@@ -208,6 +208,7 @@ class Q_CORE_EXPORT QEventDispatcherCoreFoundation : public QAbstractEventDispat
public:
explicit QEventDispatcherCoreFoundation(QObject *parent = 0);
+ void startingUp() override;
~QEventDispatcherCoreFoundation();
bool processEvents(QEventLoop::ProcessEventsFlags flags) override;
@@ -239,11 +240,11 @@ protected:
, processedPostedEvents(false), processedTimers(false)
, deferredWakeUp(false), deferredUpdateTimers(false) {}
- QEventLoop::ProcessEventsFlags flags;
- bool wasInterrupted;
- bool processedPostedEvents;
- bool processedTimers;
- bool deferredWakeUp;
+ QAtomicInt flags;
+ QAtomicInteger<char> wasInterrupted;
+ QAtomicInteger<char> processedPostedEvents;
+ QAtomicInteger<char> processedTimers;
+ QAtomicInteger<char> deferredWakeUp;
bool deferredUpdateTimers;
};
@@ -258,6 +259,7 @@ private:
QTimerInfoList m_timerInfoList;
CFRunLoopTimerRef m_runLoopTimer;
CFRunLoopTimerRef m_blockedRunLoopTimer;
+ QCFType<CFRunLoopRef> m_runLoop;
bool m_overdueTimerScheduled;
QCFSocketNotifier m_cfSocketNotifier;