Skip to content

Commit

Permalink
fix(core): fix deadlock in on_menu_event, closes #5254 (#5257)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Sep 28, 2022
1 parent 08a4449 commit ae65951
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 172 deletions.
5 changes: 5 additions & 0 deletions .changes/menu-deadlock.md
@@ -0,0 +1,5 @@
---
"tauri": "patch"
---

Fix a deadlock when modifying the menu in the `on_menu_event` closure.
15 changes: 7 additions & 8 deletions core/tauri/src/window.rs
Expand Up @@ -773,14 +773,13 @@ impl<R: Runtime> Window<R> {
pub fn on_menu_event<F: Fn(MenuEvent) + Send + 'static>(&self, f: F) -> uuid::Uuid {
let menu_ids = self.window.menu_ids.clone();
self.window.dispatcher.on_menu_event(move |event| {
f(MenuEvent {
menu_item_id: menu_ids
.lock()
.unwrap()
.get(&event.menu_item_id)
.unwrap()
.clone(),
})
let id = menu_ids
.lock()
.unwrap()
.get(&event.menu_item_id)
.unwrap()
.clone();
f(MenuEvent { menu_item_id: id })
})
}
}
Expand Down

0 comments on commit ae65951

Please sign in to comment.