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>
This commit is contained in:
Andrew Knight 2014-08-12 14:33:58 +03:00
parent 5621a7c501
commit 2be0bf0765

View File

@ -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;