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.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/bluetooth/qbluetoothserver_winrt.cpp b/src/bluetooth/qbluetoothserver_winrt.cpp
index ddd71c21..08aa45b4 100644
--- a/src/bluetooth/qbluetoothserver_winrt.cpp
+++ b/src/bluetooth/qbluetoothserver_winrt.cpp
@@ -44,6 +44,9 @@
#include <QtCore/QLoggingCategory>
#include <QtCore/private/qeventdispatcher_winrt_p.h>
+#ifdef CLASSIC_APP_BUILD
+#define Q_OS_WINRT
+#endif
#include <qfunctions_winrt.h>
#include <windows.networking.h>
@@ -70,6 +73,9 @@ QHash<QBluetoothServerPrivate *, int> __fakeServerPorts;
QBluetoothServerPrivate::QBluetoothServerPrivate(QBluetoothServiceInfo::Protocol sType)
: maxPendingConnections(1), serverType(sType), m_lastError(QBluetoothServer::NoError), socket(0)
{
+#ifdef CLASSIC_APP_BUILD
+ CoInitialize(NULL);
+#endif
socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
}
@@ -79,6 +85,12 @@ QBluetoothServerPrivate::~QBluetoothServerPrivate()
__fakeServerPorts.remove(this);
if (socket)
delete socket;
+#ifdef CLASSIC_APP_BUILD
+ // If we do not reset that pointer, socketListener will go out of scope after CoUninitialize was
+ // called, which will lead to a crash.
+ socketListener = nullptr;
+ CoUninitialize();
+#endif
}
bool QBluetoothServerPrivate::isListening() const