decoder: Cancel file loading on decoder drop

That will probably at least work for scrolling quickly
through images. It will however usually not cancel an ongoing
decoding process.

Issue #155

Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/210>
This commit is contained in:
Sophie Herold 2023-04-27 22:05:44 +02:00 • committed by Marge Bot
parent 6d7623b15a
commit 7c227f75a8
6 changed files with 56 additions and 48 deletions

View file

@ -217,8 +217,9 @@ impl Decoder {
fn guess_format(file: &gio::File) -> anyhow::Result<Option<image_rs::ImageFormat>> {
let mut buf = Vec::new();
// TODO: allow to cancel
let fs_file = file
.to_buf_read()
.to_buf_read(&gio::Cancellable::new())
.context(gettext("Could not open image"))?;
fs_file
.take(64)