mirror of
https://github.com/italicsjenga/muda.git
synced 2024-12-23 20:11:29 +11:00
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:
parent
8a949c2216
commit
923af09abf
5
.changes/checked-borrow-panic.md
Normal file
5
.changes/checked-borrow-panic.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"muda": "patch"
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix panic when updating a `CheckMenuItem` right after it was clicked.
|
|
@ -106,6 +106,7 @@ fn main() {
|
||||||
&window_m,
|
&window_m,
|
||||||
&PredefinedMenuItem::separator(),
|
&PredefinedMenuItem::separator(),
|
||||||
&check_custom_i_1,
|
&check_custom_i_1,
|
||||||
|
&check_custom_i_2,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
window_m.append_items(&[
|
window_m.append_items(&[
|
||||||
|
|
|
@ -101,6 +101,7 @@ fn main() {
|
||||||
&window_m,
|
&window_m,
|
||||||
&PredefinedMenuItem::separator(),
|
&PredefinedMenuItem::separator(),
|
||||||
&check_custom_i_1,
|
&check_custom_i_1,
|
||||||
|
&check_custom_i_2,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
window_m.append_items(&[
|
window_m.append_items(&[
|
||||||
|
|
|
@ -4,9 +4,8 @@
|
||||||
|
|
||||||
use crate::{accelerator::Accelerator, icon::Icon, MenuItemExt, MenuItemType};
|
use crate::{accelerator::Accelerator, icon::Icon, MenuItemExt, MenuItemType};
|
||||||
|
|
||||||
/// A check menu item inside a [`Menu`] or [`Submenu`]
|
/// An icon menu item inside a [`Menu`] or [`Submenu`]
|
||||||
/// and usually contains a text and a check mark or a similar toggle
|
/// and usually contains an icon and a text.
|
||||||
/// that corresponds to a checked and unchecked states.
|
|
||||||
///
|
///
|
||||||
/// [`Menu`]: crate::Menu
|
/// [`Menu`]: crate::Menu
|
||||||
/// [`Submenu`]: crate::Submenu
|
/// [`Submenu`]: crate::Submenu
|
||||||
|
|
|
@ -1041,10 +1041,9 @@ impl CheckMenuItem {
|
||||||
|
|
||||||
let id = self_.id;
|
let id = self_.id;
|
||||||
let self_c = self.0.clone();
|
let self_c = self.0.clone();
|
||||||
|
let is_syncing_checked_state = self_.is_syncing_checked_state.clone();
|
||||||
item.connect_toggled(move |i| {
|
item.connect_toggled(move |i| {
|
||||||
let should_dispatch = self_c
|
let should_dispatch = is_syncing_checked_state
|
||||||
.borrow()
|
|
||||||
.is_syncing_checked_state
|
|
||||||
.compare_exchange(false, true, Ordering::Release, Ordering::Relaxed)
|
.compare_exchange(false, true, Ordering::Release, Ordering::Relaxed)
|
||||||
.is_ok();
|
.is_ok();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue