Skip to content

Commit

Permalink
Remove signal handlers when finalising Bluetooth
Browse files Browse the repository at this point in the history
The Bluetooth widget seems to spam the log with PangoLayout errors. This
happens when a widget tries to write to a text layout that has been
finalised. The traceback shows that the call was from a signal handler
so we should disconnect these handlers when the widget is finalised.
  • Loading branch information
elParaguayo committed Dec 16, 2023
1 parent 6669a44 commit d5b8e19
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions libqtile/widget/bluetooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,3 +677,20 @@ def hide(self):
self._line_index = 0
self.show_adapter = False
self.refresh()

def finalize(self):
"""Remove dbus signal handlers before finalising."""
# Clearing dicts will call the __del__ method on the stored objects
# which has been defined to remove signal handlers
self.devices.clear()
self.adapters.clear()

# Remove object manager's handlers
self.object_manager.off_interfaces_added(self._interface_added)
self.object_manager.off_interfaces_removed(self._interface_removed)

# Disconnect the bus connection
self.bus.disconnect()
self.bus = None

base._TextBox.finalize(self)

0 comments on commit d5b8e19

Please sign in to comment.