Skip to content

Commit

Permalink
fix(macos/dialog): avoid setting empty default_path (#9784)
Browse files Browse the repository at this point in the history
closes #7566

ref: #4065
ref: #4028
ref: #9762
  • Loading branch information
amrbashir committed May 15, 2024
1 parent 36b082a commit 704260b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/macos-dialog-crash-default-path-empty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": "patch:bug"
---

Fix dialog crash on macOS when the `default_path` value is empty.
4 changes: 4 additions & 0 deletions core/tauri/src/endpoints/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ fn set_default_path(
mut dialog_builder: FileDialogBuilder,
default_path: PathBuf,
) -> FileDialogBuilder {
if default_path.as_os_str().is_empty() {
return dialog_builder;
}

// we need to adjust the separator on Windows: https://github.com/tauri-apps/tauri/issues/8074
let default_path: PathBuf = default_path.components().collect();
if default_path.is_file() || !default_path.exists() {
Expand Down

0 comments on commit 704260b

Please sign in to comment.