summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qeventdispatcher_winrt.cpp
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-03-16 12:38:50 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-25 12:59:36 +0100
commit7f41e56ec3e69569b62e9ee76537a1123fc66bfc (patch)
treeffcce644544d9ab53b92a35efa92cf10c1e674a5 /src/corelib/kernel/qeventdispatcher_winrt.cpp
parent15be1e8c069b6b7b846d3e16f6a814c4a52e4165 (diff)
WinRT: Prevent GUI dispatcher lookup from non-GUI thread
When we create an event dispatcher outside of the main thread, we shouldn't be looking up the core event dispatcher as it will fail. This ends up printing a scary warning for all e.g. Qt Quick apps when in reality nothing bad actually happened. Task-number: QTBUG-35327 Change-Id: I2060f0a9d4baffc42ca727e8d4e1ef7c13f6a2df Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
Diffstat (limited to 'src/corelib/kernel/qeventdispatcher_winrt.cpp')
-rw-r--r--src/corelib/kernel/qeventdispatcher_winrt.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp
index 56f4ac40de..1d4b57642c 100644
--- a/src/corelib/kernel/qeventdispatcher_winrt.cpp
+++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp
@@ -45,6 +45,7 @@
#include <QtCore/QThread>
#include <QtCore/QHash>
#include <private/qabstracteventdispatcher_p.h>
+#include <private/qcoreapplication_p.h>
#include <wrl.h>
#include <windows.foundation.h>
@@ -109,6 +110,11 @@ QEventDispatcherWinRT::QEventDispatcherWinRT(QObject *parent)
: QAbstractEventDispatcher(*new QEventDispatcherWinRTPrivate, parent)
{
Q_D(QEventDispatcherWinRT);
+
+ // Only look up the event dispatcher in the main thread
+ if (QThread::currentThread() != QCoreApplicationPrivate::theMainThread)
+ return;
+
ComPtr<ICoreApplication> application;
HRESULT hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(),
IID_PPV_ARGS(&application));