Skip to content

Commit

Permalink
fix(core): dialog crashing on macOS when the parent is empty (#4028)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed May 3, 2022
1 parent 891eb74 commit d31167c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/fix-dialog-default-path-crash.md
@@ -0,0 +1,5 @@
---
"tauri": patch
---

Fix dialog crash on macOS when the `default_path` value is just the file name.
4 changes: 3 additions & 1 deletion core/tauri/src/endpoints/dialog.rs
Expand Up @@ -205,7 +205,9 @@ fn set_default_path(
) -> FileDialogBuilder {
if default_path.is_file() || !default_path.exists() {
if let (Some(parent), Some(file_name)) = (default_path.parent(), default_path.file_name()) {
dialog_builder = dialog_builder.set_directory(parent);
if parent.components().count() > 0 {
dialog_builder = dialog_builder.set_directory(parent);
}
dialog_builder = dialog_builder.set_file_name(&file_name.to_string_lossy().to_string());
} else {
dialog_builder = dialog_builder.set_directory(default_path);
Expand Down

0 comments on commit d31167c

Please sign in to comment.