diff options
author | Andrew Knight <andrew.knight@digia.com> | 2014-08-12 14:33:58 +0300 |
---|---|---|
committer | Andrew Knight <andrew.knight@digia.com> | 2014-08-13 21:09:45 +0200 |
commit | 2be0bf0765aae2d8c7ec794241733b170d61c981 (patch) | |
tree | 4dfc61bbc0959179ea112040e6e4686911309243 /src/corelib | |
parent | 5621a7c5014ac337d41a00ca8f53f172bd17b792 (diff) |
winrt: Fix deadlock in thread dispatcher access
An event dispatcher fetching the core dispatcher can deadlock when
looking up the window. Simplify this by only looking up the view, and
treating the event dispatcher as one which will never obtain the core
dispatcher. This fixes a deadlock which occurs when starting network
delegates.
Change-Id: Ic27f4ab6f168eb95f3de70d78d64f035c331a7f5
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_winrt.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp index c8f959a962..aec0981677 100644 --- a/src/corelib/kernel/qeventdispatcher_winrt.cpp +++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp @@ -148,12 +148,14 @@ private: hr = application->get_MainView(&view); RETURN_VOID_IF_FAILED("Failed to get the main view"); - ComPtr<ICoreWindow> window; - hr = view->get_CoreWindow(&window); - RETURN_VOID_IF_FAILED("Failed to get the core window"); + ComPtr<ICoreApplicationView2> view2; + hr = view.As(&view2); + RETURN_VOID_IF_FAILED("Failed to cast the main view"); - hr = window->get_Dispatcher(&coreDispatcher); - RETURN_VOID_IF_FAILED("Failed to get the core dispatcher"); + hr = view2->get_Dispatcher(&coreDispatcher); + if (hr == HRESULT_FROM_WIN32(ERROR_NOT_FOUND)) // expected in thread pool cases + return; + RETURN_VOID_IF_FAILED("Failed to get core dispatcher"); thread = QThread::currentThread(); } @@ -186,7 +188,7 @@ bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags) { Q_D(QEventDispatcherWinRT); - if (d->thread != QThread::currentThread()) + if (d->thread && d->thread != QThread::currentThread()) d->fetchCoreDispatcher(); bool didProcess = false; |