diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2018-05-17 16:15:04 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2018-05-29 13:51:20 +0000 |
commit | aad6e26574ff069e080bf6461c0fb7d0fee9e403 (patch) | |
tree | d064d779bd66d9711a091f378527ba4d849c486e /src/bluetooth/qlowenergycontroller_bluez.cpp | |
parent | 88207ae868002f0b53151d2c5c2ac416284ce9c1 (diff) |
Properly invalidate services when calling disconnectService() on BlueZ
While the central role implementation properly invalidates all the
LowEnergyServicePrivate instances, peripheral mode was leaking service
instances. This is triggered when the peripheral disconnects from a client
or when the user calls disconnectService(). On the other hand
stopAdvertising() does not do that.
This patch fixes the service instance leak and ensures that the class
docs specifically state the behavior difference between stopAdvertising()
and disconnectService().
Change-Id: Ia52b141096dc1db3d0cefe3ed18c230eecccd9c0
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/bluetooth/qlowenergycontroller_bluez.cpp')
-rw-r--r-- | src/bluetooth/qlowenergycontroller_bluez.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp index d58e0ee8..d288f3ad 100644 --- a/src/bluetooth/qlowenergycontroller_bluez.cpp +++ b/src/bluetooth/qlowenergycontroller_bluez.cpp @@ -809,9 +809,12 @@ void QLowEnergyControllerPrivateBluez::resetController() securityLevelValue = -1; connectionHandle = 0; - // public API behavior requires stop of advertisement - if (role == QLowEnergyController::PeripheralRole && advertiser) - advertiser->stopAdvertising(); + if (role == QLowEnergyController::PeripheralRole) { + // public API behavior requires stop of advertisement + if (advertiser) + advertiser->stopAdvertising(); + localAttributes.clear(); + } } void QLowEnergyControllerPrivateBluez::restartRequestTimer() |