summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothserver_winrt.cpp
diff options
context:
space:
mode:
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