Skip to content

Commit d612886

Browse files
authored
Merge pull request #2582 from cwensley/curtis/mac-fix-selectfolderdialog-crash
Fix a crash that can happen when setting SelectFolderDialog.Directory on Mac
2 parents adfa141 + 987b039 commit d612886

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Eto.Mac/Forms/SelectFolderDialogHandler.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,17 @@ public string Title
3232
public string Directory
3333
{
3434
get => Control.Url?.Path ?? Control.DirectoryUrl.Path;
35-
set => Control.DirectoryUrl = NSUrl.FromFilename(value);
35+
set
36+
{
37+
try
38+
{
39+
Control.DirectoryUrl = new NSUrl(value, true);
40+
}
41+
catch
42+
{
43+
// ignore errors, can crash depending on the value when [NSUrl initFileURLWithPath:isDirectory:] returns nil
44+
}
45+
}
3646
}
3747

3848
}

0 commit comments

Comments
 (0)