Levels clipping: drop the cache when the last document closes (#3328)

With no document there is no canvas to paint the display away, so
sync_views drops its cache and texture.
This commit is contained in:
funkvay-star committed 2026-11-03 21:14:17 +04:00
1 parent fadef65cc8
commit 01cbd41e2b
2 files changed
+16

No files matched your search

+4
View File
@@ -354,6 +354,10 @@ impl PhotocraftApp {
let docs = self.session.documents();
self.channel_views.retain(|id, _| docs.iter().any(|d| d.doc.id.0 == *id));
}
// With no document left, no canvas paints the Levels clipping display to drop its cache.
if self.session.documents().is_empty() {
self.levels_clipping = None;
}
// Commands may close and reopen a preserved-ID document before the next repaint.
canvas::retain_gpu_documents(self);
}
@@ -424,6 +424,18 @@ fn a_running_job_holds_the_display() {
assert!(paint_view(&mut app, &ctx, &view(10.0)).is_some(), "back once the job is done");
}
/// Closing the last document drops the display's cache: no canvas is left to paint it away.
#[test]
fn closing_the_last_document_drops_the_cache() {
let ctx = egui::Context::default();
let mut app = ramp_app(ColorMode::Rgb, SampleType::U8);
open_levels(&mut app, json!({"inBlack": 100}), Some("shadows"));
assert!(paint_view(&mut app, &ctx, &view(10.0)).is_some());
app.run("file.close", json!({})).unwrap();
assert!(app.session.documents().is_empty());
assert!(app.levels_clipping.is_none());
}
/// A Smart Filter's Levels dialog edits the filter, not the layer's pixels: no display, and its
/// cache goes as if no Levels dialog were open, even over a pixel layer.
#[test]