Skip to content

Commit 51fa48f

Browse files
committed
cleanup on close
1 parent 5053576 commit 51fa48f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

crates/tauri/src/tray/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,13 @@ impl<R: Runtime> TrayIcon<R> {
598598

599599
impl<R: Runtime> Resource for TrayIcon<R> {
600600
fn close(self: std::sync::Arc<Self>) {
601+
self
602+
.app_handle
603+
.state::<plugin::TrayIcons>()
604+
.icons
605+
.lock()
606+
.unwrap()
607+
.remove(&self.id.0);
601608
self.app_handle.remove_tray_by_id(&self.id);
602609
}
603610
}

crates/tauri/src/tray/plugin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use crate::{
1919

2020
use super::{TrayIcon, TrayIconEvent};
2121

22-
struct TrayIcons {
23-
icons: Mutex<HashMap<String, ResourceId>>,
22+
pub(crate) struct TrayIcons {
23+
pub(crate) icons: Mutex<HashMap<String, ResourceId>>,
2424
}
2525

2626
#[derive(Deserialize)]

0 commit comments

Comments
 (0)