Skip to content

bluetooth: prevent recreating popupmenu items for removed devices

maniacx requested to merge (removed):destroy_bluetooth_item into main

Currently when a bluetooth device is removed, _removeDevice() is called and destroys the popupmenu item for the removed-device. However removed-device still reports with "paired" property "true", therefore gets returned in _getSortedDevices (via getDevice) and a new popupmenu BluetoothDeviceitem is created. This popupmenu item for removed-device wont get remove until the next _onActiveChanged() called after "paired" property changed "false".

Although a better solution is to fix, device being reported as paired=false when removed, however it involves probably fixing in Gnome-bluetooth or bluez

This commit fixes this issue by adding checks to _sync().

  1. After item is destroyed in _removeDevice(), path for removed device will be added to _removedDeviceList.
  2. When sync is called, if path in _removedDeviceList does not belong to any devices returned by _getSortedDevices, they are removed from _removedDeviceList.
  3. Device with path in _removedDeviceList and property connected=false will not create new popummenu BluetoothDeviceitem
  4. Device with path in _removedDeviceList and property connected=true will create new popummenu BluetoothDeviceitem and remove it path from _removedDeviceList (condition fo user unpairs and pairs device again)

Fixes: #7100 (closed)

Merge request reports