diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2019-02-07 17:27:18 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2019-02-12 18:34:28 +0000 |
commit | 0ad651579fe9055e52d4a6754a95de35f7b9bf52 (patch) | |
tree | 95b7123efa69c4e3477196d80788dc18e7938261 /src/plugins/platforms/cocoa | |
parent | ae94ab264ba29a41beac81a61fb39c0d4f669270 (diff) |
macOS: Don't rely on QGuiApplication::instance() during CVDisplayLink callback
The display-link callback comes in on a secondary thread, so there's a possible
race in using QGuiApplication::instance() to check whether or not we're on the
main thread.
Change-Id: Ic26bca8f5f54847a1e1b11dc92e786693c86e9de
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoascreen.mm | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index 36c11ba8af..80dd7e40d3 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -269,15 +269,12 @@ struct DeferredDebugHelper void QCocoaScreen::deliverUpdateRequests() { - if (!QGuiApplication::instance()) - return; - // The CVDisplayLink callback is a notification that it's a good time to produce a new frame. // Since the callback is delivered on a separate thread we have to marshal it over to the // main thread, as Qt requires update requests to be delivered there. This needs to happen // asynchronously, as otherwise we may end up deadlocking if the main thread calls back // into any of the CVDisplayLink APIs. - if (QThread::currentThread() != QGuiApplication::instance()->thread()) { + if (!NSThread.isMainThread) { // We're explicitly not using the data of the GCD source to track the pending updates, // as the data isn't reset to 0 until after the event handler, and also doesn't update // during the event handler, both of which we need to track late frames. |