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.
This commit is contained in:
Sophie Herold 2024-02-29 14:21:26 +01:00
parent 8b4beadcd9
commit 296817abe4
2 changed files with 7 additions and 0 deletions

View file

@ -220,6 +220,12 @@ impl imp::LpImage {
fn set_error(&self, err: Option<anyhow::Error>) {
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();