Fix: move init gdbusproxy after proxy_device_bat nullcheck

Co-authored-by: Alexis Rouillard <alexisr245@gmail.com>
pull/2886/head
Alessio Molinari 2024-03-04 16:34:45 +01:00 committed by GitHub
parent d831a45622
commit ea4b95fdd2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -340,13 +340,13 @@ auto waybar::modules::Bluetooth::getDeviceBatteryPercentage(GDBusObject* object)
-> std::optional<unsigned char> { -> std::optional<unsigned char> {
GDBusProxy* proxy_device_bat = GDBusProxy* proxy_device_bat =
G_DBUS_PROXY(g_dbus_object_get_interface(object, "org.bluez.Battery1")); G_DBUS_PROXY(g_dbus_object_get_interface(object, "org.bluez.Battery1"));
GDBusProxy* proxy_device = G_DBUS_PROXY(g_dbus_object_get_interface(object, "org.bluez.Device1"));
if (proxy_device_bat != NULL) { if (proxy_device_bat != NULL) {
unsigned char battery_percentage = getUcharProperty(proxy_device_bat, "Percentage"); unsigned char battery_percentage = getUcharProperty(proxy_device_bat, "Percentage");
g_object_unref(proxy_device_bat); g_object_unref(proxy_device_bat);
return battery_percentage; return battery_percentage;
} }
GDBusProxy* proxy_device = G_DBUS_PROXY(g_dbus_object_get_interface(object, "org.bluez.Device1"));
if (proxy_device != nullptr) { if (proxy_device != nullptr) {
auto serial = getStringProperty(proxy_device, "Address"); auto serial = getStringProperty(proxy_device, "Address");
std::transform(serial.begin(), serial.end(), serial.begin(), std::transform(serial.begin(), serial.end(), serial.begin(),