From b39d69e7f9cf4d894c23a82eaa8133a1c7c5e466 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sat, 21 Nov 2026 18:40:57 +0100 Subject: [PATCH 1/4] WIP: follow-ups to the #16197 review (#16252) From 268dd52f2561b12e8e114142474a00ef34237997 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sat, 21 Nov 2026 18:55:00 +0100 Subject: [PATCH 2/4] Fix the stale cached states the #16197 review found (#16252) - tools.setBrush keeps a stored tip that loaded only now instead of the unloaded one it compares equal to - Session::move_document moves the documents generation, so the Window menu follows a reorder - The rule facts key on every open document's revision and the scratch read-error generation - The Layers panel thumbnails key on the scratch read-error generation - The Pattern Fill dialog owns its swatch textures until it closes - The style library snapshot is derived, so the Styles panel and Layer Style dialog replay Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/brush_cmds.rs | 5 +-- crates/engine/src/preset_store/tests.rs | 21 +++++++++++ crates/engine/src/session/documents.rs | 24 ++++++++++++- crates/paint/src/brush.rs | 7 ++++ crates/ui-egui/src/command_state_trials.rs | 31 ++++++++++++++++ crates/ui-egui/src/dialogs/layer_style.rs | 4 +-- crates/ui-egui/src/dialogs/pattern_fill_ui.rs | 10 ++++-- .../src/dialogs/pattern_fill_ui/tests.rs | 21 +++++++++++ crates/ui-egui/src/menu_floor_trials.rs | 9 +++++ crates/ui-egui/src/menus/facts.rs | 20 +++++++++++ crates/ui-egui/src/panels/layers_tree.rs | 5 ++- crates/ui-egui/src/panels/preset_browser.rs | 36 +++++++++++++++---- .../src/panels/preset_browser/tests.rs | 22 ++++++++++++ 13 files changed, 201 insertions(+), 14 deletions(-) diff --git a/crates/engine/src/cmd/brush_cmds.rs b/crates/engine/src/cmd/brush_cmds.rs index c0d43e1670..7aaf0d026a 100644 --- a/crates/engine/src/cmd/brush_cmds.rs +++ b/crates/engine/src/cmd/brush_cmds.rs @@ -1300,8 +1300,9 @@ pub(crate) fn set_brush(s: &mut Session, p: &Value) -> Result { } let mut before = std::mem::replace(&mut *s.tools.brush, b); // A brush the call built anew holds a new tip source: when the tip is the one it had, it keeps its revision, so the - // views that show the tip replay. - if s.tools.brush.tip == before.tip { + // views that show the tip replay. A stored tip's equality ignores whether its full bitmap is loaded, so a tip that + // loaded only now keeps the new value: swapping the old one back would drop the bitmap (#16252). + if s.tools.brush.tip == before.tip && s.tools.brush.tip.is_loaded() == before.tip.is_loaded() { std::mem::swap(&mut s.tools.brush.tip, &mut before.tip); } // A coalesced gesture (one slider drag) journals as one call: remember the brush it started from. diff --git a/crates/engine/src/preset_store/tests.rs b/crates/engine/src/preset_store/tests.rs index 779c0e3d10..1fadbcadb2 100644 --- a/crates/engine/src/preset_store/tests.rs +++ b/crates/engine/src/preset_store/tests.rs @@ -561,6 +561,27 @@ fn the_decoded_tip_cache_stays_within_its_budget() { assert!(matches!(&*t.tools.brush.tip, TipShape::Stored(r) if r.is_loaded())); } +/// A stored tip the brush holds unloaded (its file failed to load at startup and is back) loads on the next brush +/// edit, and the brush keeps the loaded bitmap instead of the unloaded tip it compares equal to (#16252). +#[test] +fn a_brush_edit_keeps_a_stored_tip_that_loads_only_now() { + let (s, mem) = library(1, 64); + drop(s); + let mut t = Session::new(); + t.attach_preset_store(open(Box::new(mem))); + t.execute("tools.setBrush", json!({"preset": "Big 0"})).unwrap(); + if let TipShape::Stored(r) = &mut *t.tools.brush.tip { + r.full = None; + } + assert!(matches!(&*t.tools.brush.tip, TipShape::Stored(r) if !r.is_loaded()), "the tip starts unloaded"); + t.execute("tools.setBrush", json!({"brush": {"size": 30}})).unwrap(); + assert!(matches!(&*t.tools.brush.tip, TipShape::Stored(r) if r.is_loaded()), "the edit keeps the tip it loaded"); + // An edit of a brush whose tip is loaded already keeps the tip and its revision. + let revision = t.tools.brush.tip.revision(); + t.execute("tools.setBrush", json!({"brush": {"size": 40}})).unwrap(); + assert_eq!(t.tools.brush.tip.revision(), revision, "an unchanged loaded tip keeps its revision"); +} + #[test] fn missing_corrupt_or_unknown_tips_fail_when_used_without_panicking() { let (s, mem) = library(3, 64); diff --git a/crates/engine/src/session/documents.rs b/crates/engine/src/session/documents.rs index fb78e9c494..d0cc41985a 100644 --- a/crates/engine/src/session/documents.rs +++ b/crates/engine/src/session/documents.rs @@ -27,7 +27,7 @@ impl Session { &self.docs } - /// Changes whenever a document is opened, closed or renamed. + /// Changes whenever a document is opened, closed, renamed or moved to another position. pub fn documents_generation(&self) -> u64 { self.documents_generation } @@ -171,6 +171,10 @@ impl Session { pub fn move_document(&mut self, from: usize, to: usize) -> Option { let active = self.active().map(|d| d.doc.id); let to = move_item(&mut self.docs, from, to)?; + // The Window menu lists the documents by position: a move changes what each entry opens (#16252). + if to != from { + self.documents_generation = self.documents_generation.wrapping_add(1); + } self.active = active.and_then(|id| self.docs.iter().position(|d| d.doc.id == id)); self.note_active_change(); Some(to) @@ -316,4 +320,22 @@ mod document_generation_tests { session.close(0); assert_eq!(session.documents_generation(), opened.wrapping_add(1)); } + + /// A reorder that leaves the active document where it was still moves the generation: the Window menu's + /// entries open other documents now (#16252). + #[test] + fn document_generation_moves_when_documents_are_reordered() { + let mut session = Session::new(); + for _ in 0..3 { + session.add_document(Document::new("test", Size::new(2, 2), ColorMode::Rgb, SampleType::U8), None); + } + session.set_active(0); + let before = session.documents_generation(); + assert_eq!(session.move_document(1, 2), Some(2)); + assert_eq!(session.active_index(), Some(0), "the active document stays first"); + assert_eq!(session.documents_generation(), before.wrapping_add(1)); + let moved = session.documents_generation(); + assert_eq!(session.move_document(1, 1), Some(1)); + assert_eq!(session.documents_generation(), moved, "a move to the same place changes nothing"); + } } diff --git a/crates/paint/src/brush.rs b/crates/paint/src/brush.rs index 9cead7df8f..826f973047 100644 --- a/crates/paint/src/brush.rs +++ b/crates/paint/src/brush.rs @@ -125,6 +125,13 @@ impl TipShape { TipShape::Stored(r) => Some(r.bitmap()), } } + /// Whether the tip paints with its full bitmap: false only for a stored tip whose bitmap isn't loaded. + pub fn is_loaded(&self) -> bool { + match self { + TipShape::Stored(r) => r.is_loaded(), + TipShape::Round | TipShape::Sampled(_) => true, + } + } /// The tip's real pixel size (a stored tip's, not its preview's); `None` for a computed tip. pub fn bitmap_size(&self) -> Option<(u32, u32)> { match self { diff --git a/crates/ui-egui/src/command_state_trials.rs b/crates/ui-egui/src/command_state_trials.rs index 1d0c0d81f0..b1a2b19ce4 100644 --- a/crates/ui-egui/src/command_state_trials.rs +++ b/crates/ui-egui/src/command_state_trials.rs @@ -145,3 +145,34 @@ fn the_held_command_states_equal_a_fresh_build_after_each_step() { held_is_fresh(&mut h, "a pending crop"); assert!(crate::crop_ui::pending(h.state()), "the crop is pending"); } + +/// Merge Channels reads every open grayscale document, not only the active one: a change to a background document +/// moves its state in either direction (#16252). +#[test] +fn merge_channels_follows_a_change_to_a_background_document() { + let mut h = harness_of(|s| { + for _ in 0..3 { + s.execute("file.new", json!({"width": 64, "height": 64, "mode": "grayscale"})).unwrap(); + } + s.set_active(0); + }); + let merge = |h: &mut H| { + h.run_steps(2); + let merge = CommandRef::from(craft::imaging::ui::channels::ChannelsCommands::MergeChannels); + h.state().framework.held_states.states.get(&merge).is_some_and(|state| state.is_enabled()) + }; + assert!(merge(&mut h), "three grayscale documents of one size can merge"); + // A change to a background document, as a job or a script makes through `Session::document_mut`. + let resize = |h: &mut H, side: u32| { + let s = &mut h.state_mut().session; + let Some(id) = s.documents().get(2).map(|st| st.doc.id) else { panic!("three documents are open") }; + let Some(st) = s.document_mut(id) else { panic!("the third document is open") }; + st.doc.size = photocraft_geom::Size::new(side, side); + }; + resize(&mut h, 32); + assert!(!merge(&mut h), "a background document of another size leaves two to merge"); + held_is_fresh(&mut h, "resizing a background document"); + resize(&mut h, 64); + assert!(merge(&mut h), "and back at the same size, three again"); + held_is_fresh(&mut h, "resizing it back"); +} diff --git a/crates/ui-egui/src/dialogs/layer_style.rs b/crates/ui-egui/src/dialogs/layer_style.rs index b2795605ac..2574e3644e 100644 --- a/crates/ui-egui/src/dialogs/layer_style.rs +++ b/crates/ui-egui/src/dialogs/layer_style.rs @@ -611,13 +611,13 @@ fn gradient_presets(app: &PhotocraftApp) -> Vec<(String, GradientStops)> { #[derive(craft::ui::contract::MemoProps)] struct StylePresets { groups: Vec<(String, Vec)>, - library: Tracked, + library: std::sync::Arc>, } /// The Styles page's presets. fn style_presets(app: &PhotocraftApp) -> PresetSource<'static, String> { let groups = app.session.presets.styles.iter().map(|group| (group.name.clone(), group.items.iter().map(|st| st.name.clone()).collect())).collect(); - let inputs = StylePresets { groups, library: StyleLibrary::of(&app.session) }; + let inputs = StylePresets { groups, library: StyleLibrary::of(app.ctx(), &app.session) }; PresetSource::new(inputs, PresetFns::new(style_rows).thumb(style_thumb)) } diff --git a/crates/ui-egui/src/dialogs/pattern_fill_ui.rs b/crates/ui-egui/src/dialogs/pattern_fill_ui.rs index 9885075e23..228f3d76e5 100644 --- a/crates/ui-egui/src/dialogs/pattern_fill_ui.rs +++ b/crates/ui-egui/src/dialogs/pattern_fill_ui.rs @@ -44,6 +44,9 @@ pub(crate) struct Session { target: Target, opened: PatternFillOptions, preview: Option, + /// The swatches' textures. The picker paints them by id and doesn't ask the texture cache again, so the dialog + /// owns them until it closes: a cached texture would be freed once the cache is full (#16252). + swatch_textures: Vec, } impl Session { @@ -72,16 +75,19 @@ fn start(app: &mut PhotocraftApp, idx: usize, document: DocId, target: Target, o app.pattern_fill.opens += 1; let serial = app.pattern_fill.opens; let ctx = app.ctx().clone(); + let swatch_textures: Vec = + app.session.patterns.items.iter().map(|p| crate::panels::preset_browser::pattern_texture_handle(&ctx, p)).collect(); let swatches: Vec = app .session .patterns .items .iter() - .map(|p| PatternSwatch::new(p.id.clone(), p.display_name()).with_picture(crate::panels::preset_browser::pattern_texture(&ctx, p))) + .zip(&swatch_textures) + .map(|(p, texture)| PatternSwatch::new(p.id.clone(), p.display_name()).with_picture(texture.id())) .collect(); let dialog = PatternFillDialog::new(options.clone(), swatches).canvas(CanvasHost::primary(app, idx).canvas_id()); let id = app.framework.dialogs.open(dialog); - app.pattern_fill.session = Some(Session { serial, document, target, opened: options, preview: None }); + app.pattern_fill.session = Some(Session { serial, document, target, opened: options, preview: None, swatch_textures }); id } diff --git a/crates/ui-egui/src/dialogs/pattern_fill_ui/tests.rs b/crates/ui-egui/src/dialogs/pattern_fill_ui/tests.rs index a548fad559..91d6efc59d 100644 --- a/crates/ui-egui/src/dialogs/pattern_fill_ui/tests.rs +++ b/crates/ui-egui/src/dialogs/pattern_fill_ui/tests.rs @@ -327,3 +327,24 @@ fn a_replaced_or_deleted_edit_target_is_not_previewed_or_committed() { assert_eq!(*app.session.active().unwrap().doc, *deleted); assert_eq!(steps(&app), count, "a stale OK adds no History step"); } + +/// The picker paints its swatches by texture id and doesn't ask the texture cache again, so the dialog owns them: +/// emptying the cache (as it frees textures once it holds more than its capacity) leaves every swatch, and closing +/// the dialog frees them (#16252). +#[test] +fn the_open_dialog_keeps_its_swatch_textures_when_the_texture_cache_lets_go() { + use craft::ui::primitives::textures::TextureCache; + let mut app = app(); + let ctx = app.ctx().clone(); + let allocated = |ctx: &egui::Context| ctx.tex_manager().read().num_allocated(); + TextureCache::clear(&ctx); + let before = allocated(&ctx); + let patterns = app.session.patterns.items.len(); + assert!(patterns > 0, "the library has patterns"); + crate::menus::invoke(&mut app, &ctx, cmds::CREATE, json!({})).unwrap(); + let dialog = app.framework.dialogs.open_dialogs()[0].id; + TextureCache::clear(&ctx); + assert!(allocated(&ctx) >= before + patterns, "the {patterns} swatches outlive the cache"); + cancel(&mut app, dialog); + assert_eq!(allocated(&ctx), before, "closing the dialog frees them"); +} diff --git a/crates/ui-egui/src/menu_floor_trials.rs b/crates/ui-egui/src/menu_floor_trials.rs index 9fdb3eb08a..ed2696b9b7 100644 --- a/crates/ui-egui/src/menu_floor_trials.rs +++ b/crates/ui-egui/src/menu_floor_trials.rs @@ -156,6 +156,15 @@ fn the_held_menu_model_equals_a_fresh_build_after_each_step() { held_is_fresh(&mut h, "closing it"); h.state_mut().session.saved_to("/tmp/Renamed.psd".into()); held_is_fresh(&mut h, "a save that renames the document"); + // Three documents, the first active: moving the second after the third keeps the active document where it was, + // and the Window menu's second entry opens the other document now (#16252). + for _ in 0..2 { + h.state_mut().session.execute("file.new", json!({"width": 200, "height": 100})).unwrap(); + } + h.state_mut().session.set_active(0); + held_is_fresh(&mut h, "opening two more documents"); + assert_eq!(h.state_mut().session.move_document(1, 2), Some(2)); + held_is_fresh(&mut h, "reordering the documents behind the active one"); } #[test] diff --git a/crates/ui-egui/src/menus/facts.rs b/crates/ui-egui/src/menus/facts.rs index 936d742d50..4732b7800b 100644 --- a/crates/ui-egui/src/menus/facts.rs +++ b/crates/ui-egui/src/menus/facts.rs @@ -44,6 +44,13 @@ struct Documents<'a> { /// The active document, by its `Tracked` revision, which moves with every change to it: its content, layers, /// selection, history, mode, mask and view state, which most rules read. active: Option<&'a Tracked>, + /// Every open document's revision in tab order, folded into one value: rules that read other documents than the + /// active one (Merge Channels needs grayscale documents of the active one's size) follow their changes (#16252). + all: u64, + /// The scratch read-error generation: a tile that fails to read shows zeros through `&self`, and the real pixels + /// again once it reads, without moving its document's revision. Rules that read pixels (the align commands read + /// content bounds) follow both (#16252). + scratch: u64, /// A running job greys the commands that would change its document. jobs: (bool, Option), /// Smart Objects › Edit Contents' parent: whether the active document is a smart object's contents. @@ -174,6 +181,17 @@ impl<'a> MenuFacts<'a> { } } +/// The revisions of `documents` in their order, folded into one value that moves when any of them changes or they +/// are reordered. A fixed size, so the key is the same few bytes however many documents are open. +fn all_revisions(documents: &[Tracked]) -> u64 { + use std::hash::{Hash, Hasher}; + let mut hasher = std::hash::DefaultHasher::new(); + for document in documents { + document.revision().hash(&mut hasher); + } + hasher.finish() +} + impl<'a> RuleFacts<'a> { /// What the rules read in `app`'s current state. pub(crate) fn of(app: &'a PhotocraftApp) -> RuleFacts<'a> { @@ -186,6 +204,8 @@ impl<'a> RuleFacts<'a> { active_generation: s.active_generation(), active_index: s.active_index(), active: s.active_tracked(), + all: all_revisions(s.documents()), + scratch: photocraft_raster::spill::read_error_generation(), jobs: (s.has_jobs(), s.active_job().map(|job| job.id.0)), smart_child: active.is_some_and(|d| s.smart_links.iter().any(|link| link.child == d.doc.id)), fade: s.edit_state.fade.as_ref().map(|fade| (fade.doc, fade.revision)), diff --git a/crates/ui-egui/src/panels/layers_tree.rs b/crates/ui-egui/src/panels/layers_tree.rs index 2524a2a54a..25e10df30d 100644 --- a/crates/ui-egui/src/panels/layers_tree.rs +++ b/crates/ui-egui/src/panels/layers_tree.rs @@ -744,7 +744,10 @@ impl ThumbSource> for PhotoThumbs<'_> { }, _ => 0, }; - Revision::of(&(shown, clip, self.doc.size.width, self.doc.size.height)) + // A tile that fails to read shows zeros, and its pixels again once it reads, without moving its surface's + // generation: the scratch read-error generation moves with both (#16252). + let scratch = photocraft_raster::spill::read_error_generation(); + Revision::of(&(shown, clip, self.doc.size.width, self.doc.size.height, scratch)) } fn render(&self, key: &LayerThumb, request: &ThumbRequest) -> ThumbRender { diff --git a/crates/ui-egui/src/panels/preset_browser.rs b/crates/ui-egui/src/panels/preset_browser.rs index 78975d8024..d37691d0bc 100644 --- a/crates/ui-egui/src/panels/preset_browser.rs +++ b/crates/ui-egui/src/panels/preset_browser.rs @@ -229,6 +229,12 @@ fn pattern_image(pattern: &photocraft_doc::Pattern) -> ColorImage { image } +/// A texture of `pattern`'s swatch that its holder owns: it stays while the handle lives, where a cached texture +/// lasts only while something asks for it every frame. +pub(crate) fn pattern_texture_handle(ctx: &egui::Context, pattern: &photocraft_doc::Pattern) -> egui::TextureHandle { + ctx.load_texture(format!("photocraft/pattern-swatch/{}", pattern.id), pattern_image(pattern), egui::TextureOptions::LINEAR) +} + /// The cached texture of `pattern`'s swatch. pub(crate) fn pattern_texture(ctx: &egui::Context, pattern: &photocraft_doc::Pattern) -> egui::TextureId { TextureCache::texture(ctx, ("pattern", pattern.id.clone()), || pattern_image(pattern)) @@ -355,10 +361,15 @@ pub(crate) struct StyleLibrary { } impl StyleLibrary { - /// The app's styles and patterns now. - pub(crate) fn of(session: &photocraft_engine::Session) -> Tracked { - let styles = session.presets.styles.iter().flat_map(|group| group.items.iter().cloned()).collect(); - Tracked::new(StyleLibrary { styles, patterns: session.patterns.clone() }) + /// The app's styles and patterns now, derived from the presets' revision and the pattern library's + /// [`patterns_key`]: built again only when one of them changed, so an unchanged library is the same `Tracked` and + /// the views that show it replay (#16252). + pub(crate) fn of(ctx: &egui::Context, session: &photocraft_engine::Session) -> std::sync::Arc> { + let facts = (session.presets.revision(), patterns_key(&session.patterns)); + craft::ui::runtime::derived::derived(ctx, egui::Id::unique("photocraft-style-library"), &facts, || { + let styles = session.presets.styles.iter().flat_map(|group| group.items.iter().cloned()).collect(); + Tracked::new(StyleLibrary { styles, patterns: session.patterns.clone() }) + }) } /// Paints the thumbnail of the style `name`. A picture is rendered on a texture miss only, under one key for @@ -374,8 +385,21 @@ impl StyleLibrary { } } +/// What tells one state of `patterns` from another: each pattern's id and size in order, the revision that moves when +/// a pattern's pixels are replaced under its id, and how many are held unloaded. A pattern library has no `Tracked` +/// revision of its own. +fn patterns_key(patterns: &PatternLibrary) -> u64 { + use std::hash::{Hash, Hasher}; + let mut hasher = std::hash::DefaultHasher::new(); + (patterns.pixels_rev, patterns.stored.len(), patterns.items.len()).hash(&mut hasher); + for pattern in &patterns.items { + (&pattern.id, pattern.width, pattern.height).hash(&mut hasher); + } + hasher.finish() +} + /// A Styles panel thumbnail. -fn style_thumb(inputs: &PanelInputs>, cx: &ContentPainterCx, rect: Rect, info: ThumbInfo<'_, PresetKey>) { +fn style_thumb(inputs: &PanelInputs>>, cx: &ContentPainterCx, rect: Rect, info: ThumbInfo<'_, PresetKey>) { if let PresetKey::Item(name) = info.key { inputs.thumbs.paint(cx, rect, name); } @@ -386,7 +410,7 @@ fn style_thumb(inputs: &PanelInputs>, cx: &ContentPainterC pub fn styles_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let folders = style_folders(app); let names = names_of(&folders); - let source = panel_source(PanelInputs::new(&app.ui.presets_ui, STYLES, folders, StyleLibrary::of(&app.session)), style_thumb); + let source = panel_source(PanelInputs::new(&app.ui.presets_ui, STYLES, folders, StyleLibrary::of(ui.ctx(), &app.session)), style_thumb); let zone = canvas_zone(app); let look = Look { room_height: Some(STYLES_HEIGHT), ..Look::default() }; let (events, keys) = show(&mut app.ui.presets_ui, zone, ui, STYLES, &source, look); diff --git a/crates/ui-egui/src/panels/preset_browser/tests.rs b/crates/ui-egui/src/panels/preset_browser/tests.rs index ff04ff3e0b..fb406ea63c 100644 --- a/crates/ui-egui/src/panels/preset_browser/tests.rs +++ b/crates/ui-egui/src/panels/preset_browser/tests.rs @@ -114,3 +114,25 @@ fn preset_drops_map_through_the_ruler_inset() { let doc = crate::canvas::document_display::doc_point_at(&app, centre).expect("the canvas centre is on the document"); assert!((doc.x - 32.0).abs() < 1.0 && (doc.y - 24.0).abs() < 1.0, "the canvas centre is the document centre: {doc:?}"); } + +/// The style library the Styles panel and the Layer Style dialog paint from is one snapshot while the styles and the +/// patterns stay as they are, so their views replay; a change to either builds a new one (#16252). +#[test] +fn the_style_library_snapshot_is_kept_until_the_styles_or_patterns_change() { + let ctx = egui::Context::default(); + PhotocraftApp::setup_context(&ctx, Default::default()); + let of = |session: &photocraft_engine::Session| { + let mut revision = None; + let _ = ctx.run(Default::default(), |ctx| revision = Some(StyleLibrary::of(ctx, session).revision())); + revision + }; + let mut session = photocraft_engine::Session::new(); + let first = of(&session); + assert!(first.is_some()); + assert_eq!(of(&session), first, "an unchanged library is the same snapshot"); + session.presets.edit(|presets| presets.styles.clear()); + let styles = of(&session); + assert_ne!(styles, first, "a change to the styles builds a new snapshot"); + session.patterns.items.pop(); + assert_ne!(of(&session), styles, "a change to the patterns builds a new snapshot"); +} From 22dad4f071a5e1b7c3320132542da01fc946392e Mon Sep 17 00:00:00 2001 From: David Mann Date: Sat, 21 Nov 2026 19:15:09 +0100 Subject: [PATCH 3/4] Fix the new trials' compile errors and texture delta Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/command_state_trials.rs | 2 +- crates/ui-egui/src/dialogs/pattern_fill_ui.rs | 4 ++-- crates/ui-egui/src/panels/preset_browser/tests.rs | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/command_state_trials.rs b/crates/ui-egui/src/command_state_trials.rs index b1a2b19ce4..7a10593ff5 100644 --- a/crates/ui-egui/src/command_state_trials.rs +++ b/crates/ui-egui/src/command_state_trials.rs @@ -167,7 +167,7 @@ fn merge_channels_follows_a_change_to_a_background_document() { let s = &mut h.state_mut().session; let Some(id) = s.documents().get(2).map(|st| st.doc.id) else { panic!("three documents are open") }; let Some(st) = s.document_mut(id) else { panic!("the third document is open") }; - st.doc.size = photocraft_geom::Size::new(side, side); + std::sync::Arc::make_mut(st.doc_mut()).size = photocraft_geom::Size::new(side, side); }; resize(&mut h, 32); assert!(!merge(&mut h), "a background document of another size leaves two to merge"); diff --git a/crates/ui-egui/src/dialogs/pattern_fill_ui.rs b/crates/ui-egui/src/dialogs/pattern_fill_ui.rs index 228f3d76e5..297b84ea3d 100644 --- a/crates/ui-egui/src/dialogs/pattern_fill_ui.rs +++ b/crates/ui-egui/src/dialogs/pattern_fill_ui.rs @@ -46,7 +46,7 @@ pub(crate) struct Session { preview: Option, /// The swatches' textures. The picker paints them by id and doesn't ask the texture cache again, so the dialog /// owns them until it closes: a cached texture would be freed once the cache is full (#16252). - swatch_textures: Vec, + _swatch_textures: Vec, } impl Session { @@ -87,7 +87,7 @@ fn start(app: &mut PhotocraftApp, idx: usize, document: DocId, target: Target, o .collect(); let dialog = PatternFillDialog::new(options.clone(), swatches).canvas(CanvasHost::primary(app, idx).canvas_id()); let id = app.framework.dialogs.open(dialog); - app.pattern_fill.session = Some(Session { serial, document, target, opened: options, preview: None, swatch_textures }); + app.pattern_fill.session = Some(Session { serial, document, target, opened: options, preview: None, _swatch_textures: swatch_textures }); id } diff --git a/crates/ui-egui/src/panels/preset_browser/tests.rs b/crates/ui-egui/src/panels/preset_browser/tests.rs index fb406ea63c..7c2031c62f 100644 --- a/crates/ui-egui/src/panels/preset_browser/tests.rs +++ b/crates/ui-egui/src/panels/preset_browser/tests.rs @@ -123,7 +123,8 @@ fn the_style_library_snapshot_is_kept_until_the_styles_or_patterns_change() { PhotocraftApp::setup_context(&ctx, Default::default()); let of = |session: &photocraft_engine::Session| { let mut revision = None; - let _ = ctx.run(Default::default(), |ctx| revision = Some(StyleLibrary::of(ctx, session).revision())); + let mut out = ctx.run_ui(Default::default(), |ui| revision = Some(StyleLibrary::of(ui.ctx(), session).revision())); + out.textures_delta.clear(); revision }; let mut session = photocraft_engine::Session::new(); From 439b955cc62719bc8dae85fa6ee0d2c968a4fff1 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sat, 21 Nov 2026 19:20:58 +0100 Subject: [PATCH 4/4] Name the reordered documents so the menu trial sees the move Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/menu_floor_trials.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/menu_floor_trials.rs b/crates/ui-egui/src/menu_floor_trials.rs index ed2696b9b7..f61e567f98 100644 --- a/crates/ui-egui/src/menu_floor_trials.rs +++ b/crates/ui-egui/src/menu_floor_trials.rs @@ -158,8 +158,8 @@ fn the_held_menu_model_equals_a_fresh_build_after_each_step() { held_is_fresh(&mut h, "a save that renames the document"); // Three documents, the first active: moving the second after the third keeps the active document where it was, // and the Window menu's second entry opens the other document now (#16252). - for _ in 0..2 { - h.state_mut().session.execute("file.new", json!({"width": 200, "height": 100})).unwrap(); + for name in ["Second", "Third"] { + h.state_mut().session.execute("file.new", json!({"width": 200, "height": 100, "name": name})).unwrap(); } h.state_mut().session.set_active(0); held_is_fresh(&mut h, "opening two more documents");