diff --git a/crates/ui-egui/src/panels/library_problem.rs b/crates/ui-egui/src/panels/library_problem.rs index 67ce88ca6..1b4efd523 100644 --- a/crates/ui-egui/src/panels/library_problem.rs +++ b/crates/ui-egui/src/panels/library_problem.rs @@ -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) -> Option> { - 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()?; diff --git a/crates/ui-egui/src/tests_launch_library.rs b/crates/ui-egui/src/tests_launch_library.rs index 13f59fc8f..0f0abbf78 100644 --- a/crates/ui-egui/src/tests_launch_library.rs +++ b/crates/ui-egui/src/tests_launch_library.rs @@ -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");