diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index 83eff15ea..ad99920a4 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -2102,7 +2102,7 @@ impl Runtime for Wry { .insert( id, TrayContext { - tray: Rc::new(Mutex::new(Some(tray))), + tray: Rc::new(RefCell::new(Some(tray))), listeners: Rc::new(RefCell::new(listeners)), items: Rc::new(RefCell::new(items)), }, @@ -2653,7 +2653,7 @@ fn handle_user_message( trays.insert( tray_id, TrayContext { - tray: Rc::new(Mutex::new(Some(tray))), + tray: Rc::new(RefCell::new(Some(tray))), listeners: Rc::new(RefCell::new(listeners)), items: Rc::new(RefCell::new(items)), }, @@ -2682,14 +2682,14 @@ fn handle_user_message( } } TrayMessage::UpdateMenu(menu) => { - if let Some(tray) = &mut *tray_context.tray.lock().unwrap() { + if let Some(tray) = &mut *tray_context.tray.borrow_mut() { let mut items = HashMap::new(); tray.set_menu(&to_wry_context_menu(&mut items, menu)); *tray_context.items.borrow_mut() = items; } } TrayMessage::UpdateIcon(icon) => { - if let Some(tray) = &mut *tray_context.tray.lock().unwrap() { + if let Some(tray) = &mut *tray_context.tray.borrow_mut() { if let Ok(icon) = TrayIcon::try_from(icon) { tray.set_icon(icon.0); } @@ -2697,18 +2697,18 @@ fn handle_user_message( } #[cfg(target_os = "macos")] TrayMessage::UpdateIconAsTemplate(is_template) => { - if let Some(tray) = &mut *tray_context.tray.lock().unwrap() { + if let Some(tray) = &mut *tray_context.tray.borrow_mut() { tray.set_icon_as_template(is_template); } } #[cfg(target_os = "macos")] TrayMessage::UpdateTitle(title) => { - if let Some(tray) = &mut *tray_context.tray.lock().unwrap() { + if let Some(tray) = &mut *tray_context.tray.borrow_mut() { tray.set_title(&title); } } TrayMessage::UpdateTooltip(tooltip) => { - if let Some(tray) = &mut *tray_context.tray.lock().unwrap() { + if let Some(tray) = &mut *tray_context.tray.borrow_mut() { tray.set_tooltip(&tooltip); } } @@ -2716,7 +2716,7 @@ fn handle_user_message( // already handled } TrayMessage::Destroy(tx) => { - *tray_context.tray.lock().unwrap() = None; + *tray_context.tray.borrow_mut() = None; tray_context.listeners.borrow_mut().clear(); tray_context.items.borrow_mut().clear(); tx.send(Ok(())).unwrap(); diff --git a/core/tauri-runtime-wry/src/system_tray.rs b/core/tauri-runtime-wry/src/system_tray.rs index eab2e7b06..fb5511d43 100644 --- a/core/tauri-runtime-wry/src/system_tray.rs +++ b/core/tauri-runtime-wry/src/system_tray.rs @@ -48,7 +48,7 @@ pub type SystemTrayItems = Rc>>; #[derive(Clone, Default)] pub struct TrayContext { - pub tray: Rc>>, + pub tray: Rc>>, pub listeners: SystemTrayEventListeners, pub items: SystemTrayItems, }