From 296817abe47ed609a778019cb7218a67a561aa81 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Thu, 29 Feb 2024 14:21:26 +0100 Subject: [PATCH] image/loading: Display first error, ignore second Usually the first error is the relevant one. So show this one. Why we get more than one error at all is a bit unclear. --- src/decoder/formats/svg.rs | 1 + src/widgets/image/loading.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/decoder/formats/svg.rs b/src/decoder/formats/svg.rs index aed2b18..50a3039 100644 --- a/src/decoder/formats/svg.rs +++ b/src/decoder/formats/svg.rs @@ -69,6 +69,7 @@ impl Svg { let (wakeup, wakeup_resv) = mpsc::unbounded(); updater.clone().spawn_error_handled(async move { + log::trace!("Setting up SVG loader"); let mut loader = glycin::Loader::new(file); #[cfg(feature = "disable-glycin-sandbox")] diff --git a/src/widgets/image/loading.rs b/src/widgets/image/loading.rs index 0a73dcf..49a38bd 100644 --- a/src/widgets/image/loading.rs +++ b/src/widgets/image/loading.rs @@ -220,6 +220,12 @@ impl imp::LpImage { fn set_error(&self, err: Option) { log::debug!("Decoding error: {err:?}"); + + // Keeping first error instead of replacing with new error + if err.is_some() && self.error.borrow().is_some() { + return; + } + self.error.replace(err.as_ref().map(|x| x.to_string())); self.obj().notify_error();