From 27c0ae9ff94d545fb43446179e95276112b9f2cc Mon Sep 17 00:00:00 2001 From: Christian Wassmuth Date: Thu, 22 Aug 2019 11:28:02 +0200 Subject: bluez-dbus: Invalidate btle service when it has disappeared When a previous existing service UUID has disapperad we will now invalidate that service and remove it from the service list [ChangeLog][QtBluetooth][BlueZ-DBus] Invalidate btle service when it has disappeared Fixes: QTBUG-77766 Change-Id: Id03a054c1f781dbcef5614623c2dae9b156d12e2 Reviewed-by: Alex Blasche --- src/bluetooth/qlowenergycontroller_bluezdbus.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/bluetooth/qlowenergycontroller_bluezdbus.cpp') diff --git a/src/bluetooth/qlowenergycontroller_bluezdbus.cpp b/src/bluetooth/qlowenergycontroller_bluezdbus.cpp index 2a0fafdf..5dde8774 100644 --- a/src/bluetooth/qlowenergycontroller_bluezdbus.cpp +++ b/src/bluetooth/qlowenergycontroller_bluezdbus.cpp @@ -112,6 +112,23 @@ void QLowEnergyControllerPrivateBluezDBus::devicePropertiesChanged( } } } + + if (changedProperties.contains(QStringLiteral("UUIDs"))) { + const QStringList newUuidStringList = changedProperties.value(QStringLiteral("UUIDs")).toStringList(); + QVector newUuidList; + for (const QString &uuidString : newUuidStringList) + newUuidList.append(QBluetoothUuid(uuidString)); + + for (const QBluetoothUuid &uuid : serviceList.keys()) { + if (!newUuidList.contains(uuid)) { + qCDebug(QT_BT_BLUEZ) << __func__ << "Service" << uuid << "has been removed"; + QSharedPointer service = serviceList.take(uuid); + service->setController(nullptr); + dbusServices.remove(uuid); + } + } + } + } else if (interface == QStringLiteral("org.bluez.Battery1")) { qCDebug(QT_BT_BLUEZ) << "######" << interface << changedProperties; if (changedProperties.contains(QStringLiteral("Percentage"))) { -- cgit v1.2.3