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.
This commit is contained in:
Sven Lafebre
2026-11-09 20:58:11 +01:00
parent 05ada26dc1
commit 619cd7aa0c
2 changed files with 21 additions and 2 deletions
+3 -2
View File
@@ -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(&params) {
// A failure to begin leaves no interaction: the preview below then reports it.
} else if !app.session.in_interaction() && d.fields.get(TRIED) != Some(&params) {
// 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, &params) {
Ok(_) => {
@@ -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() {