From 7c9965685e48423fcf3e99c4b5d49ca0e33153c2 Mon Sep 17 00:00:00 2001 From: Iohann Rabeson Date: Sun, 24 Nov 2024 21:11:50 -0500 Subject: [PATCH] Fix issue where with no filter added no files are selectable on Windows (#211) (#224) fix #221 --- CHANGELOG.md | 1 + src/backend/win_cid/file_dialog/dialog_ffi.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dddbe14..cd421e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ## 0.15.1 - Update `ashpd` to 0.10. +- Fix issue where with no filter added no files are selectable on Windows (#211). ## 0.15.0 - Move from `objc` crates to `objc2` crates. diff --git a/src/backend/win_cid/file_dialog/dialog_ffi.rs b/src/backend/win_cid/file_dialog/dialog_ffi.rs index cb9ca53..f4dbd3f 100644 --- a/src/backend/win_cid/file_dialog/dialog_ffi.rs +++ b/src/backend/win_cid/file_dialog/dialog_ffi.rs @@ -173,17 +173,14 @@ impl IDialog { } fn add_filters(&self, filters: &[crate::file_dialog::Filter]) -> Result<()> { - { - let Some(first_filter) = filters.first() else { - return Ok(()); - }; + if let Some(first_filter) = filters.first() { if let Some(first_extension) = first_filter.extensions.first() { let extension = str_to_vec_u16(first_extension); unsafe { self.0.set_default_extension(&extension)? } } } - let f_list = { + let mut f_list = { let mut f_list = Vec::new(); let mut ext_string = String::new(); @@ -205,6 +202,10 @@ impl IDialog { f_list }; + if f_list.is_empty() { + f_list.push((str_to_vec_u16("All Files"), str_to_vec_u16("*.*"))); + } + let spec: Vec<_> = f_list .iter() .map(|(name, ext)| COMDLG_FILTERSPEC {