fix(macos/dialog): avoid setting empty default_path (#9784)

closes #7566

ref: https://github.com/tauri-apps/tauri/issues/4065
ref: https://github.com/tauri-apps/tauri/pull/4028
ref: https://github.com/tauri-apps/tauri/issues/9762
This commit is contained in:
Amr Bashir
2024-05-15 18:45:11 +03:00
committed by GitHub
parent 36b082a9c8
commit 704260bb3c
2 changed files with 9 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"tauri": "patch:bug"
---
Fix dialog crash on macOS when the `default_path` value is empty.

View File

@@ -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() {