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>
This commit is contained in:
parent
15be1e8c06
commit
7f41e56ec3
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user