From 0df3c84c0f66e9ca156859fe2b4ad1a832e9b6a6 Mon Sep 17 00:00:00 2001 From: Lukas Fink Date: Fri, 14 Jun 2024 14:00:55 +0200 Subject: [PATCH] Fix device list not being updated on selecting new bluetooth controller --- src/modules/bluetooth.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/modules/bluetooth.cpp b/src/modules/bluetooth.cpp index 478d0073..c3c8c2c3 100644 --- a/src/modules/bluetooth.cpp +++ b/src/modules/bluetooth.cpp @@ -301,16 +301,25 @@ auto waybar::modules::Bluetooth::onObjectAdded(GDBusObjectManager* manager, auto waybar::modules::Bluetooth::onObjectRemoved(GDBusObjectManager* manager, GDBusObject* object, gpointer user_data) -> void { - GDBusProxy* proxy_controller = - G_DBUS_PROXY(g_dbus_object_get_interface(object, "org.bluez.Adapter1")); + Bluetooth* bt = static_cast(user_data); + GDBusProxy* proxy_controller; + + if (!bt->cur_controller_.has_value()) { + return; + } + + proxy_controller = G_DBUS_PROXY(g_dbus_object_get_interface(object, "org.bluez.Adapter1")); if (proxy_controller != NULL) { std::string object_path = g_dbus_object_get_object_path(object); - Bluetooth* bt = static_cast(user_data); if (object_path == bt->cur_controller_->path) { bt->cur_controller_ = bt->findCurController(); + if (bt->cur_controller_.has_value()) { + bt->connected_devices_.clear(); + bt->findConnectedDevices(bt->cur_controller_->path, bt->connected_devices_); + } bt->dp.emit(); }