#1290: no drop toast on frames with nothing dropped

The drop code runs every frame, mostly with nothing dropped; while the
launch list was up, hold_dropped then toasted "The photos are imported once
a library is open" on every frame, hiding any other toast (the presets
one among them). An empty drop is a no-op now. Found by CodeRabbit on
#2701; the test steps frames with the list up and fails without the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
francoisgn
2026-10-23 23:25:40 +03:00
co-authored by Claude Opus 5.5
parent da434b0598
commit c6fe7281f5
2 changed files with 7 additions and 1 deletions
+2 -1
View File
@@ -437,7 +437,8 @@ pub fn holds_drops(app: &LightcraftApp) -> bool {
/// opens, instead of going into the session the next library replaces. Gives the photos back when
/// a library is open or Continue Without Saving was chosen.
pub fn hold_dropped(app: &mut LightcraftApp, ctx: &egui::Context, photos: Vec<String>) -> Option<Vec<String>> {
if !holds_drops(app) {
// called every frame, with nothing dropped most of the time: only a real drop is held (and toasted)
if photos.is_empty() || !holds_drops(app) {
return Some(photos);
}
let problem = app.library_problem.as_mut()?;
@@ -844,7 +844,12 @@ fn photos_dropped_on_the_launch_list_go_into_the_library_chosen() {
let png = lightcraft_codecs::encode_png(&lightcraft_codecs::EncodeImage::rgba8(&img), &lightcraft_codecs::EncodeMeta::default()).unwrap();
let photo = dir.join("a.png");
std::fs::write(&photo, png).unwrap();
// frames with nothing dropped (the drop code runs every frame) hold nothing and say nothing
settle(&mut h);
assert!(h.app.ui.toast.is_none(), "{:?}", h.app.ui.toast);
let ctx = h.view.ctx.clone();
assert_eq!(crate::panels::library_problem::hold_dropped(&mut h.app, &ctx, Vec::new()), Some(Vec::new()));
assert!(h.app.ui.toast.is_none(), "an empty drop says nothing: {:?}", h.app.ui.toast);
let photos = vec![photo.to_string_lossy().into_owned()];
assert!(crate::panels::library_problem::holds_drops(&h.app));
assert_eq!(crate::panels::library_problem::hold_dropped(&mut h.app, &ctx, photos.clone()), None, "held while no library is open");