From 469e721d2bf86737e36960db2bfa607c665c5f24 Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Sun, 22 Jan 2023 13:31:15 -0500 Subject: [PATCH] image: Use async function to load file info GdkPixbuf provides `file_info_future ()` to load the file info asynchronously, using the gio thread pool. That means we don't need to spawn a thread ourselves for it. --- src/widgets/image.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/widgets/image.rs b/src/widgets/image.rs index a309b9f..03d33d1 100644 --- a/src/widgets/image.rs +++ b/src/widgets/image.rs @@ -584,12 +584,9 @@ impl LpImage { self.notify("metadata"); log::debug!("Loading image size"); - let (_, x, y) = util::spawn( - "image-load-size", - glib::clone!(@strong path => move || gdk_pixbuf::Pixbuf::file_info(&path)), - ) - .await? - .context(i18n("Failed to load image size"))?; + let (_, x, y) = gdk_pixbuf::Pixbuf::file_info_future(path.clone()) + .await? + .context(i18n("Failed to load image size"))?; imp.image_original_size.set((x, y)); self.notify("image-size");