summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothserver_winrt.cpp
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2017-08-07 13:25:45 +0200
committerOliver Wolff <oliver.wolff@qt.io>2017-08-30 13:33:10 +0000
commit8f1bd6c6c017a0e28160c5325d1c5c86a3e16384 (patch)
treef0c52eef43831d813ac100f674cb712f598b4297 /src/bluetooth/qbluetoothserver_winrt.cpp
parentdbd70341ea47122239ec90304f1d6c66c34a4acd (diff)
windows: Make sure everything is properly CoInitialized on desktop use
Task-number: QTBUG-61566 Change-Id: I5f8ff2c3e8a841ab8c5a3fb465d0be4b003d7a2b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/bluetooth/qbluetoothserver_winrt.cpp')
-rw-r--r--src/bluetooth/qbluetoothserver_winrt.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bluetooth/qbluetoothserver_winrt.cpp b/src/bluetooth/qbluetoothserver_winrt.cpp
index f478dc93..08aa45b4 100644
--- a/src/bluetooth/qbluetoothserver_winrt.cpp
+++ b/src/bluetooth/qbluetoothserver_winrt.cpp
@@ -73,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);
}
@@ -82,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