Skip to content

Commit f0a82fc

Browse files
Handle null shell results from file picker
1 parent 9d49010 commit f0a82fc

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/OpenClaw.Tray.WinUI/Helpers/Win32FilePickerHelper.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,28 @@ private static Task<IReadOnlyList<string>> PickFilesAsync(IntPtr ownerHwnd, stri
5555
if (allowMultiple)
5656
{
5757
dialog.GetResults(out var items);
58+
if (items is null)
59+
{
60+
dialog.GetResult(out var fallbackItem);
61+
if (fallbackItem is null)
62+
{
63+
tcs.SetResult(Array.Empty<string>());
64+
return;
65+
}
66+
67+
fallbackItem.GetDisplayName(SIGDN.SIGDN_FILESYSPATH, out var fallbackFilePath);
68+
tcs.SetResult(new[] { fallbackFilePath });
69+
return;
70+
}
71+
5872
items.GetCount(out var count);
5973
var paths = new List<string>((int)count);
6074
for (uint i = 0; i < count; i++)
6175
{
6276
items.GetItemAt(i, out var multiItem);
77+
if (multiItem is null)
78+
continue;
79+
6380
multiItem.GetDisplayName(SIGDN.SIGDN_FILESYSPATH, out var multiFilePath);
6481
paths.Add(multiFilePath);
6582
}

0 commit comments

Comments
 (0)