summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2018-04-13 17:00:19 +0200
committerAlex Blasche <alexander.blasche@qt.io>2018-04-16 05:46:22 +0000
commit5c160d9fdf9d93307bcdfabef4a78eb7dc18694e (patch)
tree72ed34738129f08d269513269a8ff4471965a1c9 /src
parent96afc728c508708da7a5fa16266dcafafcb60d0b (diff)
BlueZ: Fix crash when discovering GATT service without readable items
The jobs list might be empty and calling last() causes an assert in QVector. This implies the current process under discovery does not have any descriptors or characteristics which are readable. In such cases no async read requests have to be put forward and the discovery is already done. Change-Id: I8417bfcd146866cb16c295c9e9d4890270574a56 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/bluetooth/qlowenergycontroller_bluezdbus.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/bluetooth/qlowenergycontroller_bluezdbus.cpp b/src/bluetooth/qlowenergycontroller_bluezdbus.cpp
index e9087642..afc4b8c1 100644
--- a/src/bluetooth/qlowenergycontroller_bluezdbus.cpp
+++ b/src/bluetooth/qlowenergycontroller_bluezdbus.cpp
@@ -537,8 +537,12 @@ void QLowEnergyControllerPrivateBluezDBus::discoverServiceDetails(const QBluetoo
serviceData->endHandle = runningHandle++;
// last job is last step of service discovery
- GattJob &lastJob = jobs.last();
- lastJob.flags.setFlag(GattJob::LastServiceDiscovery, true);
+ if (!jobs.isEmpty()) {
+ GattJob &lastJob = jobs.last();
+ lastJob.flags.setFlag(GattJob::LastServiceDiscovery, true);
+ } else {
+ serviceData->setState(QLowEnergyService::ServiceDiscovered);
+ }
scheduleNextJob();
}