From e55137b72f546a911950157dfaa0cd7c94a3ea72 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sun, 22 Nov 2026 23:38:29 +0000 Subject: [PATCH] Select and Mask previews again after a document edit The workspace keyed its pending preview on the request alone, so after HostedWorkspace::set_source the same request found the old job and no preview of the edited document started. The key carries WorkspaceCx::revision, as Vanishing Point and Wide Angle do. --- crates/imaging/src/ui/select_mask/mod.rs | 14 ++++++++++---- crates/imaging/tests/it/select_mask.rs | 7 ++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/crates/imaging/src/ui/select_mask/mod.rs b/crates/imaging/src/ui/select_mask/mod.rs index 4e3816acd..684f14468 100644 --- a/crates/imaging/src/ui/select_mask/mod.rs +++ b/crates/imaging/src/ui/select_mask/mod.rs @@ -481,7 +481,13 @@ impl SelectMaskWorkspace { /// The events of the methods that ran between passes come first. A second pass of a frame reports only what its /// own input did, since the first pass took the frame's steps and commands. OK closes an open polygon first, so the /// result carries it. - fn pass(&mut self, ui: &mut Ui, source: &dyn SelectMaskSource, open: Bind<'_, bool>) -> WorkspacePass { + fn pass( + &mut self, + ui: &mut Ui, + source: &dyn SelectMaskSource, + revision: u64, + open: Bind<'_, bool>, + ) -> WorkspacePass { // pc: crates/ui-egui/src/dialogs/select_mask_ui.rs:1812 `show`, :1375 `keys`, :870 // `enter`, :881 `escape`. let env = Env::of(ui); @@ -511,7 +517,7 @@ impl SelectMaskWorkspace { .sides(|ui, cx| { let mut guard = this.borrow_mut(); let work: &mut SelectMaskWorkspace = &mut guard; - let status = cx.pending(key.clone(), || source.preview_job(&request)).clone(); + let status = cx.pending((revision, key.clone()), || source.preview_job(&request)).clone(); *side_status.borrow_mut() = Some(status.clone()); side_panel_open.set(None); *side_pick.borrow_mut() = None; @@ -910,8 +916,8 @@ impl FullWindowWorkspace for SelectMaskWorkspace { const KEY: &'static str = "select.selectAndMask"; fn show(&mut self, ui: &mut Ui, cx: WorkspaceCx<'_, Self::Source>) -> WorkspacePass { - let WorkspaceCx { source, open, .. } = cx; - self.pass(ui, source, open) + let WorkspaceCx { source, revision, open, .. } = cx; + self.pass(ui, source, revision, open) } /// The settings, and the bar's `tool`, `mode` (`"add"`, `"subtract"`), `size` (of the current tool), `hardness`, diff --git a/crates/imaging/tests/it/select_mask.rs b/crates/imaging/tests/it/select_mask.rs index 66fce98b3..d7ea08c19 100644 --- a/crates/imaging/tests/it/select_mask.rs +++ b/crates/imaging/tests/it/select_mask.rs @@ -129,7 +129,7 @@ fn press_label(fixture: &mut Fixture, label: &str) { #[trial] fn select_mask_preview_is_asked_for_only_when_it_changes() { - let (mut fixture, _, jobs) = open(); + let (mut fixture, app, jobs) = open(); let first = jobs.load(Ordering::SeqCst); assert_eq!(first, 1, "one preview for the opening state"); fixture.frame(vec![pointer::moved(canvas_point(&fixture, Vec2::ZERO))]); @@ -137,6 +137,11 @@ fn select_mask_preview_is_asked_for_only_when_it_changes() { assert_eq!(jobs.load(Ordering::SeqCst), first, "hovering changes nothing"); press_label(&mut fixture, "Invert"); assert_eq!(jobs.load(Ordering::SeqCst), first + 1, "an edit asks for a new preview"); + let size = PixelSize::new(DOCUMENT[0], DOCUMENT[1]); + let edited: Arc = Arc::new(Source { image: Solid { size }, jobs: Arc::clone(&jobs) }); + app.borrow_mut().host.get_mut::>().expect("the workspace is open").set_source(edited); + fixture.settle(); + assert_eq!(jobs.load(Ordering::SeqCst), first + 2, "a document edit asks for a new preview of the same request"); } // The view keys work from inside the workspace with no help from the app: K picks Black & White, X held hides the