diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index 6ea22bd4a..e14c9b19d 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -1832,7 +1832,7 @@ impl Runtime for Wry { .listeners .lock() .unwrap() - .insert(id, Box::new(f)); + .insert(id, Arc::new(Box::new(f))); id } @@ -2355,7 +2355,8 @@ fn handle_event_loop( .. } => { let event = SystemTrayEvent::MenuItemClick(menu_id.0); - for handler in tray_context.listeners.lock().unwrap().values() { + let listeners = tray_context.listeners.lock().unwrap().clone(); + for handler in listeners.values() { handler(&event); } } diff --git a/core/tauri-runtime-wry/src/system_tray.rs b/core/tauri-runtime-wry/src/system_tray.rs index 568c08433..db16ee0ae 100644 --- a/core/tauri-runtime-wry/src/system_tray.rs +++ b/core/tauri-runtime-wry/src/system_tray.rs @@ -32,7 +32,7 @@ use std::{ }; pub type SystemTrayEventHandler = Box; -pub type SystemTrayEventListeners = Arc>>; +pub type SystemTrayEventListeners = Arc>>>; pub type SystemTrayItems = Arc>>; #[derive(Debug, Clone)]