Skip to content

Commit

Permalink
Fix issue where with no filter added no files are selectable on Windo…
Browse files Browse the repository at this point in the history
…ws (#211) (#224)

fix #221
  • Loading branch information
IohannRabeson authored Nov 25, 2024
1 parent 3d09f55 commit 7c99656
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 6 additions & 5 deletions src/backend/win_cid/file_dialog/dialog_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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 {
Expand Down

0 comments on commit 7c99656

Please sign in to comment.