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:
parent
6d7623b15a
commit
7c227f75a8
6 changed files with 56 additions and 48 deletions
|
|
@ -182,13 +182,13 @@ pub trait BufReadSeek: std::io::BufRead + std::io::Seek {}
|
|||
impl BufReadSeek for std::io::BufReader<gio::InputStreamRead<gio::FileInputStream>> {}
|
||||
|
||||
pub trait ToBufRead {
|
||||
fn to_buf_read(&self) -> anyhow::Result<Box<dyn BufReadSeek>>;
|
||||
fn to_buf_read(&self, cancellable: &gio::Cancellable) -> anyhow::Result<Box<dyn BufReadSeek>>;
|
||||
}
|
||||
|
||||
impl ToBufRead for gio::File {
|
||||
fn to_buf_read(&self) -> anyhow::Result<Box<dyn BufReadSeek>> {
|
||||
fn to_buf_read(&self, cancellable: &gio::Cancellable) -> anyhow::Result<Box<dyn BufReadSeek>> {
|
||||
let read = self
|
||||
.read(gio::Cancellable::NONE)
|
||||
.read(Some(cancellable))
|
||||
.context(gettext("Failed to open image"))?
|
||||
.into_read();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue