propertiesView: Use strong file reference

This fixes issues with file info not loading.

Closes #96
This commit is contained in:
Sophie Herold 2023-03-09 23:46:04 +01:00
parent 5217d39cd3
commit 9b532f93f3

View file

@ -102,7 +102,9 @@ mod imp {
glib::ParamSpecObject::builder::<LpImage>("image") glib::ParamSpecObject::builder::<LpImage>("image")
.explicit_notify() .explicit_notify()
.build(), .build(),
glib::ParamSpecObject::builder::<LpImageMetadata>("metadata").build(), glib::ParamSpecObject::builder::<LpImageMetadata>("metadata")
.explicit_notify()
.build(),
] ]
}); });
@ -222,8 +224,8 @@ impl LpPropertiesView {
// Here we build the future: // Here we build the future:
let (handle, reg) = AbortHandle::new_pair(); let (handle, reg) = AbortHandle::new_pair();
let fut = Abortable::new( let fut = Abortable::new(
clone!(@weak self as view, @weak file => async move { clone!(@weak self as view, @strong file => async move {
if let Ok(info) = util::query_attributes_future( let info_result = util::query_attributes_future(
&file, &file,
vec![ vec![
gio::FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, gio::FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
@ -232,8 +234,11 @@ impl LpPropertiesView {
gio::FILE_ATTRIBUTE_TIME_MODIFIED, gio::FILE_ATTRIBUTE_TIME_MODIFIED,
], ],
) )
.await { .await;
view.on_info_loaded(info, &file);
match info_result {
Ok(info) => view.on_info_loaded(info, &file),
Err(err) => log::warn!("Failed to load file info: {err}"),
} }
}), }),
reg, reg,