mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-03 10:11:15 +02:00
fix(core): deadlock when closing the app on a tray event handler (#3771)
This commit is contained in:
committed by
GitHub
parent
def8a62bd3
commit
9489963e00
@@ -1832,7 +1832,7 @@ impl<T: UserEvent> Runtime<T> for Wry<T> {
|
||||
.listeners
|
||||
.lock()
|
||||
.unwrap()
|
||||
.insert(id, Box::new(f));
|
||||
.insert(id, Arc::new(Box::new(f)));
|
||||
id
|
||||
}
|
||||
|
||||
@@ -2355,7 +2355,8 @@ fn handle_event_loop<T: UserEvent>(
|
||||
..
|
||||
} => {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ use std::{
|
||||
};
|
||||
|
||||
pub type SystemTrayEventHandler = Box<dyn Fn(&SystemTrayEvent) + Send>;
|
||||
pub type SystemTrayEventListeners = Arc<Mutex<HashMap<Uuid, SystemTrayEventHandler>>>;
|
||||
pub type SystemTrayEventListeners = Arc<Mutex<HashMap<Uuid, Arc<SystemTrayEventHandler>>>>;
|
||||
pub type SystemTrayItems = Arc<Mutex<HashMap<u16, WryCustomMenuItem>>>;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
Reference in New Issue
Block a user