From 987b0393e6030c3b4f5fb3ca8c6125afccaa9eef Mon Sep 17 00:00:00 2001 From: Curtis Wensley Date: Fri, 17 Nov 2023 12:50:55 -0800 Subject: [PATCH] Fix a crash that can happen when setting SelectFolderDialog.Directory on Mac --- src/Eto.Mac/Forms/SelectFolderDialogHandler.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Eto.Mac/Forms/SelectFolderDialogHandler.cs b/src/Eto.Mac/Forms/SelectFolderDialogHandler.cs index 24e3c0da8..17e77ffd2 100644 --- a/src/Eto.Mac/Forms/SelectFolderDialogHandler.cs +++ b/src/Eto.Mac/Forms/SelectFolderDialogHandler.cs @@ -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 + } + } } }