Skip to content

Commit 1084632

Browse files
Applied fix suggested by @andrii-riabchun for context menu operations. Should fix #424
1 parent 2c2b24d commit 1084632

3 files changed

Lines changed: 17 additions & 20 deletions

File tree

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ iced_test = "0.14" # for UI testing
7171

7272
[dev-dependencies.iced]
7373
version = "0.14.0"
74-
features = ["advanced"]
74+
features = ["tokio", "advanced"]
7575

7676
[dependencies]
7777
iced_core = { version = "0.14.0" }

src/widget/context_menu.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -180,25 +180,12 @@ where
180180
renderer: &Renderer,
181181
operation: &mut dyn Operation<()>,
182182
) {
183-
let s: &mut State = state.state.downcast_mut();
184-
let show = self.force_open.unwrap_or(s.show);
185-
186-
if show {
187-
let content = self.overlay_instance.get_or_insert_with(&self.overlay);
188-
state.children[1].diff(&*content);
189-
190-
content
191-
.as_widget_mut()
192-
.operate(&mut state.children[1], layout, renderer, operation);
193-
} else {
194-
self.overlay_instance = None;
195-
self.underlay.as_widget_mut().operate(
196-
&mut state.children[0],
197-
layout,
198-
renderer,
199-
operation,
200-
);
201-
}
183+
// `iced_runtime::UserInterface::operate` already traverses the active overlay
184+
// separately. Operating the overlay content here with the underlay layout can
185+
// desynchronize the widget tree and trigger button/layout panics.
186+
self.underlay
187+
.as_widget_mut()
188+
.operate(&mut state.children[0], layout, renderer, operation);
202189
}
203190

204191
fn update(

0 commit comments

Comments
 (0)