summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-02-02 09:49:54 +0100
committerLiang Qi <liang.qi@qt.io>2018-02-02 09:49:54 +0100
commit787821571b4a7cce8eb9faccb0fed10ee944d8a5 (patch)
treec57b78ba6808175d20d0fd30d6a531146e4cfa4e /src
parent4fec6958d7af80c10453d4d45c2e9e90500a7549 (diff)
parentdf376c4c27d16f70ba69925553acfc69287b269a (diff)
Merge remote-tracking branch 'origin/5.9' into 5.105.10
Diffstat (limited to 'src')
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp25
-rw-r--r--src/bluetooth/qbluetoothsocket_p.cpp1
-rw-r--r--src/bluetooth/qbluetoothsocket_winrt.cpp5
3 files changed, 23 insertions, 8 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
index c97325cc..309804a8 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_winrt.cpp
@@ -92,7 +92,7 @@ private:
QBluetoothDeviceDiscoveryAgent::DiscoveryMethod mode);
void gatherDeviceInformation(IDeviceInformation *deviceInfo,
QBluetoothDeviceDiscoveryAgent::DiscoveryMethod mode);
- void gatherMultipleDeviceInformation(IVectorView<DeviceInformation *> *devices,
+ void gatherMultipleDeviceInformation(quint32 deviceCount, IVectorView<DeviceInformation *> *devices,
QBluetoothDeviceDiscoveryAgent::DiscoveryMethod mode);
void setupLEDeviceWatcher();
void classicBluetoothInfoFromDeviceIdAsync(HSTRING deviceId);
@@ -207,7 +207,20 @@ void QWinRTBluetoothDeviceDiscoveryWorker::onDeviceDiscoveryFinished(IAsyncOpera
HRESULT hr;
hr = op->GetResults(&devices);
Q_ASSERT_SUCCEEDED(hr);
- gatherMultipleDeviceInformation(devices.Get(), mode);
+ quint32 deviceCount;
+ hr = devices->get_Size(&deviceCount);
+ Q_ASSERT_SUCCEEDED(hr);
+
+ // For classic discovery only paired devices will be found. If we only do classic disovery and
+ // no device is found, the scan is finished.
+ if (requestedModes == QBluetoothDeviceDiscoveryAgent::ClassicMethod &&
+ deviceCount == 0) {
+ finishDiscovery();
+ return;
+ }
+
+ m_pendingPairedDevices += deviceCount;
+ gatherMultipleDeviceInformation(deviceCount, devices.Get(), mode);
}
void QWinRTBluetoothDeviceDiscoveryWorker::gatherDeviceInformation(IDeviceInformation *deviceInfo, QBluetoothDeviceDiscoveryAgent::DiscoveryMethod mode)
@@ -222,15 +235,11 @@ void QWinRTBluetoothDeviceDiscoveryWorker::gatherDeviceInformation(IDeviceInform
classicBluetoothInfoFromDeviceIdAsync(deviceId.Get());
}
-void QWinRTBluetoothDeviceDiscoveryWorker::gatherMultipleDeviceInformation(IVectorView<DeviceInformation *> *devices, QBluetoothDeviceDiscoveryAgent::DiscoveryMethod mode)
+void QWinRTBluetoothDeviceDiscoveryWorker::gatherMultipleDeviceInformation(quint32 deviceCount, IVectorView<DeviceInformation *> *devices, QBluetoothDeviceDiscoveryAgent::DiscoveryMethod mode)
{
- quint32 deviceCount;
- HRESULT hr = devices->get_Size(&deviceCount);
- Q_ASSERT_SUCCEEDED(hr);
- m_pendingPairedDevices += deviceCount;
for (quint32 i = 0; i < deviceCount; ++i) {
ComPtr<IDeviceInformation> device;
- hr = devices->GetAt(i, &device);
+ HRESULT hr = devices->GetAt(i, &device);
Q_ASSERT_SUCCEEDED(hr);
gatherDeviceInformation(device.Get(), mode);
}
diff --git a/src/bluetooth/qbluetoothsocket_p.cpp b/src/bluetooth/qbluetoothsocket_p.cpp
index 39d483d6..4c716005 100644
--- a/src/bluetooth/qbluetoothsocket_p.cpp
+++ b/src/bluetooth/qbluetoothsocket_p.cpp
@@ -50,6 +50,7 @@ QBluetoothSocketPrivate::QBluetoothSocketPrivate()
socketType(QBluetoothServiceInfo::UnknownProtocol),
state(QBluetoothSocket::UnconnectedState),
socketError(QBluetoothSocket::NoSocketError),
+ discoveryAgent(0),
secFlags(QBluetooth::NoSecurity)
{
#ifndef QT_IOS_BLUETOOTH
diff --git a/src/bluetooth/qbluetoothsocket_winrt.cpp b/src/bluetooth/qbluetoothsocket_winrt.cpp
index ec511974..8fa1338f 100644
--- a/src/bluetooth/qbluetoothsocket_winrt.cpp
+++ b/src/bluetooth/qbluetoothsocket_winrt.cpp
@@ -129,6 +129,9 @@ public:
~SocketWorker()
{
+ }
+ void close()
+ {
if (Q_UNLIKELY(m_initialReadOp)) {
ComPtr<IAsyncInfo> info;
HRESULT hr = m_initialReadOp.As(&info);
@@ -312,6 +315,7 @@ QBluetoothSocketPrivate::QBluetoothSocketPrivate()
socketType(QBluetoothServiceInfo::UnknownProtocol),
state(QBluetoothSocket::UnconnectedState),
socketError(QBluetoothSocket::NoSocketError),
+ discoveryAgent(0),
secFlags(QBluetooth::NoSecurity),
m_worker(new SocketWorker())
{
@@ -404,6 +408,7 @@ void QBluetoothSocketPrivate::abort()
this, &QBluetoothSocketPrivate::handleNewData);
disconnect(m_worker, &SocketWorker::socketErrorOccured,
this, &QBluetoothSocketPrivate::handleError);
+ m_worker->close();
m_worker->deleteLater();
if (socket != -1) {