The following:
|
assert!(matches!(prev, Some(Poll::Pending)), "unexpected state"); |
Doesn't take into account that the user may want to forget the image before it's loaded. Here:
|
let _ = self.cache.lock().remove(uri); |
or here:
|
self.cache.lock().clear(); |
The following would be a better alternative (untested):
let mut cache = cache.lock();
if cache.contains(&uri) {
cache.insert(uri.clone(), Poll::Ready(result));
ctx.request_repaint();
log::trace!("finished loading {uri:?}");
}
else {
log::trace!("cancelled loading {uri:?}");
}
This assert was recently added by @bircni and @lucasmerlin in 58b2ac8. It's possible similar assertions were added in other loaders.