status-area: Fix handling of NameOwnerChanged with non-None new name (#1010)

Fixes issue where `fcitx5` app icon persists after it is no longer
running. It seems it was getting a `NameOwnerChanged` event with the
acquired name after `register_status_notifier_item()`.
This commit is contained in:
Ian Douglas Scott 2025-08-04 12:33:55 -07:00 committed by GitHub
parent d3ef5b181b
commit 1d3d869f4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -118,17 +118,19 @@ pub async fn create_service(connection: &zbus::Connection) -> zbus::Result<()> {
have_bus_name = false;
}
} else if let BusName::Unique(name) = &args.name {
let mut interface = interface.get_mut().await;
if let Some(idx) = interface
.items
.iter()
.position(|(unique_name, _)| unique_name == name)
{
let ctxt = SignalEmitter::new(&connection, OBJECT_PATH).unwrap();
let service = interface.items.remove(idx).1;
StatusNotifierWatcher::status_notifier_item_unregistered(&ctxt, &service)
.await
.unwrap();
if args.new_owner.is_none() {
let mut interface = interface.get_mut().await;
if let Some(idx) = interface
.items
.iter()
.position(|(unique_name, _)| unique_name == name)
{
let ctxt = SignalEmitter::new(&connection, OBJECT_PATH).unwrap();
let service = interface.items.remove(idx).1;
StatusNotifierWatcher::status_notifier_item_unregistered(&ctxt, &service)
.await
.unwrap();
}
}
}
}