From 619cd7aa0c1d3da2dfad5a56a4a27043feec5ee7 Mon Sep 17 00:00:00 2001 From: Sven Lafebre Date: Mon, 9 Nov 2026 20:58:11 +0100 Subject: [PATCH] A 3D dialog's Preview-off try waits for another interaction to end (#6140) begin_interaction joins an interaction already in progress, so the try replaced that interaction's preview and then cancelled it. --- crates/ui-egui/src/dialogs/effect.rs | 5 +++-- .../ui-egui/src/dialogs/tests_revolve_gizmo.rs | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/effect.rs b/crates/ui-egui/src/dialogs/effect.rs index 13e15c413f..febbc6488a 100644 --- a/crates/ui-egui/src/dialogs/effect.rs +++ b/crates/ui-egui/src/dialogs/effect.rs @@ -38,8 +38,9 @@ const TRIED: &str = "__tried"; fn three_d_refusal(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog, cmd: &str, params: Value) { if d.bool("preview") { d.fields.remove(TRIED); - } else if d.fields.get(TRIED) != Some(¶ms) { - // A failure to begin leaves no interaction: the preview below then reports it. + } else if !app.session.in_interaction() && d.fields.get(TRIED) != Some(¶ms) { + // Waits for another interaction to end: trying inside it would replace its preview and + // cancel it. A failure to begin leaves no interaction: the preview below then reports it. let _ = app.session.begin_interaction(&d.str("__label")); match app.session.preview(cmd, ¶ms) { Ok(_) => { diff --git a/crates/ui-egui/src/dialogs/tests_revolve_gizmo.rs b/crates/ui-egui/src/dialogs/tests_revolve_gizmo.rs index 87f58b12eb..75aecde466 100644 --- a/crates/ui-egui/src/dialogs/tests_revolve_gizmo.rs +++ b/crates/ui-egui/src/dialogs/tests_revolve_gizmo.rs @@ -347,6 +347,24 @@ fn a_refused_3d_effect_is_found_with_preview_off() { assert!(!h.app.session.in_interaction()); } +/// With Preview off, trying the values waits for another interaction to end: trying them during +/// one would replace its preview and cancel it. +#[test] +fn a_3d_effect_with_preview_off_leaves_another_interaction_alone() { + let mut h = Harness::extrude_dialog(&clipping_group(), false); + h.app.session.begin_interaction("Drag").unwrap(); + let d = h.app.ui.dialog.as_mut().unwrap(); + d.fields.remove("__tried"); + d.fields.remove(dialogs::form::REFUSED); + h.settle(); + assert!(h.app.session.in_interaction(), "the other interaction goes on"); + assert!(h.ok_is_on(), "nothing has tried the values yet"); + h.app.session.cancel_interaction().unwrap(); + assert!(h.shows("requires a path")); + assert!(!h.ok_is_on()); + assert!(!h.app.session.in_interaction()); +} + /// An object the effect can take keeps OK on, with Preview on or off, and shows no reason. #[test] fn an_accepted_3d_effect_keeps_ok_on() {