From 9b532f93f37a554359f23dd68ab695fbff0500d5 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Thu, 9 Mar 2023 23:46:04 +0100 Subject: [PATCH] propertiesView: Use strong file reference This fixes issues with file info not loading. Closes #96 --- src/widgets/properties_view.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/widgets/properties_view.rs b/src/widgets/properties_view.rs index 20a436b..ed58dac 100644 --- a/src/widgets/properties_view.rs +++ b/src/widgets/properties_view.rs @@ -102,7 +102,9 @@ mod imp { glib::ParamSpecObject::builder::("image") .explicit_notify() .build(), - glib::ParamSpecObject::builder::("metadata").build(), + glib::ParamSpecObject::builder::("metadata") + .explicit_notify() + .build(), ] }); @@ -222,8 +224,8 @@ impl LpPropertiesView { // Here we build the future: let (handle, reg) = AbortHandle::new_pair(); let fut = Abortable::new( - clone!(@weak self as view, @weak file => async move { - if let Ok(info) = util::query_attributes_future( + clone!(@weak self as view, @strong file => async move { + let info_result = util::query_attributes_future( &file, vec![ gio::FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, @@ -232,8 +234,11 @@ impl LpPropertiesView { gio::FILE_ATTRIBUTE_TIME_MODIFIED, ], ) - .await { - view.on_info_loaded(info, &file); + .await; + + match info_result { + Ok(info) => view.on_info_loaded(info, &file), + Err(err) => log::warn!("Failed to load file info: {err}"), } }), reg,