fix(linux): fix multiple borrow panic (#48)

* fix(linux): fix multiple borrow panic, fixes #40

* chore: update example

* update docs
This commit is contained in:
Amr Bashir 2023-02-14 14:45:35 +02:00 committed by GitHub
parent 8a949c2216
commit 923af09abf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 6 deletions

View file

@ -0,0 +1,5 @@
---
"muda": "patch"
---
Fix panic when updating a `CheckMenuItem` right after it was clicked.

View file

@ -106,6 +106,7 @@ fn main() {
&window_m,
&PredefinedMenuItem::separator(),
&check_custom_i_1,
&check_custom_i_2,
]);
window_m.append_items(&[

View file

@ -101,6 +101,7 @@ fn main() {
&window_m,
&PredefinedMenuItem::separator(),
&check_custom_i_1,
&check_custom_i_2,
]);
window_m.append_items(&[

View file

@ -4,9 +4,8 @@
use crate::{accelerator::Accelerator, icon::Icon, MenuItemExt, MenuItemType};
/// A check menu item inside a [`Menu`] or [`Submenu`]
/// and usually contains a text and a check mark or a similar toggle
/// that corresponds to a checked and unchecked states.
/// An icon menu item inside a [`Menu`] or [`Submenu`]
/// and usually contains an icon and a text.
///
/// [`Menu`]: crate::Menu
/// [`Submenu`]: crate::Submenu

View file

@ -1041,10 +1041,9 @@ impl CheckMenuItem {
let id = self_.id;
let self_c = self.0.clone();
let is_syncing_checked_state = self_.is_syncing_checked_state.clone();
item.connect_toggled(move |i| {
let should_dispatch = self_c
.borrow()
.is_syncing_checked_state
let should_dispatch = is_syncing_checked_state
.compare_exchange(false, true, Ordering::Release, Ordering::Relaxed)
.is_ok();