Skip to content

Assertion in egui_extras::FileLoader::load triggers when Context::forget_image is called while image is loading #6755

Open
@luveti

Description

@luveti

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions