From 6c59e21264c7e2f1732328d1ade1ed0f70358c28 Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Sun, 22 Jan 2023 13:52:50 -0500 Subject: [PATCH] image: Load Texture directly `gdk::Texture::from_file ()` automatically falls back to GdkPixbuf for file types Texture doesn't support natively. --- src/widgets/image.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/widgets/image.rs b/src/widgets/image.rs index 03d33d1..17ee4ba 100644 --- a/src/widgets/image.rs +++ b/src/widgets/image.rs @@ -593,14 +593,14 @@ impl LpImage { log::debug!("Loading complete image"); let texture = util::spawn( "image-load-image", - glib::clone!(@strong path => move || { - let pixbuf = gdk_pixbuf::Pixbuf::from_file(&path)?; + glib::clone!(@weak file => @default-return Err(anyhow::Error::msg(i18n("File does not exist"))), move || { log::debug!("Creating texture"); - Ok::<_,anyhow::Error>(gdk::Texture::for_pixbuf(&pixbuf)) + let texture = gdk::Texture::from_file(&file)?; + Ok::<_,anyhow::Error>(texture) }), ) .await? - .context(i18n("Failed to load image size"))?; + .context(i18n("Failed to load image"))?; imp.texture.replace(Some(texture));