summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothserver_winrt.cpp
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2017-02-02 15:14:11 +0100
committerOliver Wolff <oliver.wolff@qt.io>2017-02-03 11:06:23 +0000
commitf07c94c0037a2e9a51b8177edb757063206e00cc (patch)
treeafc3377215f89a4bcbcc4168bc0ff124873b853e /src/bluetooth/qbluetoothserver_winrt.cpp
parent69c8d41f90cc9d0c77a512615896b8c5b9eec83f (diff)
winrt: Register callbacks in Xaml thread
Change-Id: Ib32af0803e95229a1671055da4d5608f3fd3e0f6 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'src/bluetooth/qbluetoothserver_winrt.cpp')
-rw-r--r--src/bluetooth/qbluetoothserver_winrt.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/bluetooth/qbluetoothserver_winrt.cpp b/src/bluetooth/qbluetoothserver_winrt.cpp
index 28ab7e53..d37fc9e3 100644
--- a/src/bluetooth/qbluetoothserver_winrt.cpp
+++ b/src/bluetooth/qbluetoothserver_winrt.cpp
@@ -43,6 +43,7 @@
#include "qbluetoothsocket_p.h"
#include <QtCore/QLoggingCategory>
+#include <QtCore/private/qeventdispatcher_winrt_p.h>
#include <qfunctions_winrt.h>
#include <windows.networking.h>
@@ -156,11 +157,16 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
return false;
HRESULT hr;
- hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Networking_Sockets_StreamSocketListener).Get(),
- &d->socketListener);
- Q_ASSERT_SUCCEEDED(hr);
- hr = d->socketListener->add_ConnectionReceived(Callback<ClientConnectedHandler>(d, &QBluetoothServerPrivate::handleClientConnection).Get(),
- &d->connectionToken);
+ hr = QEventDispatcherWinRT::runOnXamlThread([d, this] ()
+ {
+ HRESULT hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Networking_Sockets_StreamSocketListener).Get(),
+ &d->socketListener);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = d->socketListener->add_ConnectionReceived(Callback<ClientConnectedHandler>(d, &QBluetoothServerPrivate::handleClientConnection).Get(),
+ &d->connectionToken);
+ Q_ASSERT_SUCCEEDED(hr);
+ return S_OK;
+ });
Q_ASSERT_SUCCEEDED(hr);
//We can not register an actual Rfcomm port, because the platform does not allow it