From 29bd5fa7cf7283f2d284b728e0b3339f3c9d78f2 Mon Sep 17 00:00:00 2001 From: igorgbr Date: Wed, 21 Oct 2026 08:03:52 -0300 Subject: [PATCH] fix(studio): a card or thumbnail not drawn yet no longer prints "Error loading image" image_at and package_art handed every cached path to slint::Image::load_from_path, which prints an error for each file that is missing. On a first launch that is every effect card, and after an import it is the new media's thumbnail, so the terminal filled with 'Error loading image from ... No such file or directory' while the fallbacks (bundled card, regenerated thumb) worked fine. image_at now returns None for a path that is not a file, and package_art loads through it. A file that exists but will not decode is still reported by Slint. Signed-off-by: igorgbr --- src/crates/concat/src/host.rs | 8 +++++++- src/crates/concat/src/studio.rs | 7 ++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/crates/concat/src/host.rs b/src/crates/concat/src/host.rs index e1fa92aae..23412e981 100644 --- a/src/crates/concat/src/host.rs +++ b/src/crates/concat/src/host.rs @@ -427,8 +427,14 @@ pub fn image_of(frame: &concat_core::frame::Frame) -> slint::Image { slint::Image::from_rgba8(buffer) } -/// The JPEG at `path`, if it can be read, as a Slint image. +/// The picture at `path`, if it can be read, as a Slint image. A file that +/// is not there is `None` without a word: Slint prints every load that +/// fails, and a cached picture not drawn yet is the expected case, not a +/// fault. pub fn image_at(path: &std::path::Path) -> Option { + if !path.is_file() { + return None; + } slint::Image::load_from_path(path).ok() } diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs index aa04a50f2..0e9d3f56f 100644 --- a/src/crates/concat/src/studio.rs +++ b/src/crates/concat/src/studio.rs @@ -1195,11 +1195,8 @@ fn package_art( package .folder .as_deref() - .and_then(|folder| slint::Image::load_from_path(&folder.join("preview.png")).ok()) - .or_else(|| { - let card = card_paths.get(id)?; - slint::Image::load_from_path(card).ok() - }) + .and_then(|folder| image_at(&folder.join("preview.png"))) + .or_else(|| image_at(card_paths.get(id)?)) .or_else(|| bundled_card(id)) .unwrap_or_default() })