Skip to content

Commit d31167c

Browse files
authored
fix(core): dialog crashing on macOS when the parent is empty (#4028)
1 parent 891eb74 commit d31167c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Fix dialog crash on macOS when the `default_path` value is just the file name.

core/tauri/src/endpoints/dialog.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ fn set_default_path(
205205
) -> FileDialogBuilder {
206206
if default_path.is_file() || !default_path.exists() {
207207
if let (Some(parent), Some(file_name)) = (default_path.parent(), default_path.file_name()) {
208-
dialog_builder = dialog_builder.set_directory(parent);
208+
if parent.components().count() > 0 {
209+
dialog_builder = dialog_builder.set_directory(parent);
210+
}
209211
dialog_builder = dialog_builder.set_file_name(&file_name.to_string_lossy().to_string());
210212
} else {
211213
dialog_builder = dialog_builder.set_directory(default_path);

0 commit comments

Comments
 (0)