Skip to content

Commit

Permalink
fix(macos): crash on removing menu item (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
pewsheen authored Apr 1, 2024
1 parent 6454ea2 commit 2edfbf1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-macos-crash-on-remove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"muda": patch
---

On macOS, fix a crash when removing a menu item.
6 changes: 2 additions & 4 deletions src/platform_impl/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,7 @@ impl MenuChild {
AddOp::Append => {
for menus in self.ns_menus.as_ref().unwrap().values() {
for ns_menu in menus {
let ns_menu_item: id =
item.make_ns_item_for_menu(self.ns_menu.as_ref().unwrap().0)?;
let ns_menu_item: id = item.make_ns_item_for_menu(ns_menu.0)?;
ns_menu.1.addItem_(ns_menu_item);
}
}
Expand All @@ -554,8 +553,7 @@ impl MenuChild {
AddOp::Insert(position) => {
for menus in self.ns_menus.as_ref().unwrap().values() {
for ns_menu in menus {
let ns_menu_item: id =
item.make_ns_item_for_menu(self.ns_menu.as_ref().unwrap().0)?;
let ns_menu_item: id = item.make_ns_item_for_menu(ns_menu.0)?;
let () = msg_send![ns_menu.1, insertItem: ns_menu_item atIndex: position as NSInteger];
}
}
Expand Down

0 comments on commit 2edfbf1

Please sign in to comment.