From 99bd28520da734f30a9e4029e885c700d9d15173 Mon Sep 17 00:00:00 2001 From: Jason Perlow Date: Mon, 23 Nov 2026 10:42:39 -0500 Subject: [PATCH] fix: take the UPower device-removed object path as a string libupower-glib emits device-removed with the object path, not a device object. The vapi declared a UPower.Device, so the charging indicator treated the string as an object and crashed when a Bluetooth device disconnected. Assisted-by: Claude Code:claude-sonnet-5-5 AI-Scope: Located the root cause, wrote the vapi and handler change and the reproducer that shows the crash before and the clean exit after. --- src/components/panel/device_charging_indicator.vala | 10 +++++++--- src/vapi/upower-glib.vapi | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/panel/device_charging_indicator.vala b/src/components/panel/device_charging_indicator.vala index 8fd8a5d1..76b50ff8 100644 --- a/src/components/panel/device_charging_indicator.vala +++ b/src/components/panel/device_charging_indicator.vala @@ -87,9 +87,13 @@ namespace Singularity { queue_sync(); } - private void on_device_removed(UPower.Device device) { - device.notify.disconnect(on_device_notify); - watched.remove(device); + private void on_device_removed(string object_path) { + foreach (var device in watched) { + if (device.get_object_path() != object_path) continue; + device.notify.disconnect(on_device_notify); + watched.remove(device); + break; + } queue_sync(); } diff --git a/src/vapi/upower-glib.vapi b/src/vapi/upower-glib.vapi index a41936e8..61aa9549 100644 --- a/src/vapi/upower-glib.vapi +++ b/src/vapi/upower-glib.vapi @@ -12,12 +12,13 @@ namespace UPower { public bool get_lid_is_present (); public signal void device_added (UPower.Device device); - public signal void device_removed (UPower.Device device); + public signal void device_removed (string object_path); public signal void device_changed (UPower.Device device); } [CCode (cname = "UpDevice", cprefix = "up_device_", type_id = "up_device_get_type ()")] public class Device : GLib.Object { + public unowned string get_object_path (); [NoAccessorMethod] public double percentage { get; } [NoAccessorMethod]