Skip to content

Commit

Permalink
Merge pull request #2582 from cwensley/curtis/mac-fix-selectfolderdia…
Browse files Browse the repository at this point in the history
…log-crash

Fix a crash that can happen when setting SelectFolderDialog.Directory on Mac
  • Loading branch information
cwensley authored Nov 17, 2023
2 parents adfa141 + 987b039 commit d612886
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Eto.Mac/Forms/SelectFolderDialogHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@ public string Title
public string Directory
{
get => Control.Url?.Path ?? Control.DirectoryUrl.Path;
set => Control.DirectoryUrl = NSUrl.FromFilename(value);
set
{
try
{
Control.DirectoryUrl = new NSUrl(value, true);
}
catch
{
// ignore errors, can crash depending on the value when [NSUrl initFileURLWithPath:isDirectory:] returns nil
}
}
}

}
Expand Down

0 comments on commit d612886

Please sign in to comment.