Skip to content

Commit ae65951

Browse files
authored
fix(core): fix deadlock in on_menu_event, closes #5254 (#5257)
1 parent 08a4449 commit ae65951

File tree

3 files changed

+165
-172
lines changed

3 files changed

+165
-172
lines changed

Diff for: .changes/menu-deadlock.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": "patch"
3+
---
4+
5+
Fix a deadlock when modifying the menu in the `on_menu_event` closure.

Diff for: core/tauri/src/window.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -773,14 +773,13 @@ impl<R: Runtime> Window<R> {
773773
pub fn on_menu_event<F: Fn(MenuEvent) + Send + 'static>(&self, f: F) -> uuid::Uuid {
774774
let menu_ids = self.window.menu_ids.clone();
775775
self.window.dispatcher.on_menu_event(move |event| {
776-
f(MenuEvent {
777-
menu_item_id: menu_ids
778-
.lock()
779-
.unwrap()
780-
.get(&event.menu_item_id)
781-
.unwrap()
782-
.clone(),
783-
})
776+
let id = menu_ids
777+
.lock()
778+
.unwrap()
779+
.get(&event.menu_item_id)
780+
.unwrap()
781+
.clone();
782+
f(MenuEvent { menu_item_id: id })
784783
})
785784
}
786785
}

0 commit comments

Comments
 (0)