fix: flickering

it does still reload the image,
but at least it doesn't flicker while doing so

this also exposes a problem with the error reporting,
since with so many error-reporting operations going on,
the errors that do happen are most often immediately cleared.
This commit is contained in:
electria 2026-08-09 15:32:24 -07:00
commit d9751fe2e6
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -87,9 +87,13 @@ impl State {
self.error = result.as_ref().err().map(|e| e.to_string());
if let Ok((path, handle)) = result {
self.images
.entry(path)
.and_modify(|e| *e = MaybeImage::Loaded(handle));
let entry = self.images.entry(path).or_default();
if matches!(entry, MaybeImage::Loaded(_)) {
self.error = Some("tried to load already-loaded image!".into())
} else {
*entry = MaybeImage::Loaded(handle)
}
}
}