mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
[Peek] Fix crash when opening Peek with no files selected (#26470)
* catch exception * Check count of items to avoid the exception being thrown * Fix regression from #26364 --------- Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
This commit is contained in:
@@ -87,10 +87,20 @@ namespace Peek.UI.Helpers
|
||||
|
||||
private static IShellItemArray? GetShellItemArray(IShellBrowser shellBrowser, bool onlySelectedFiles)
|
||||
{
|
||||
var shellView = (IFolderView)shellBrowser.QueryActiveShellView();
|
||||
var selectionFlag = onlySelectedFiles ? (uint)_SVGIO.SVGIO_SELECTION : (uint)_SVGIO.SVGIO_ALLVIEW;
|
||||
shellView.Items(selectionFlag, typeof(IShellItemArray).GUID, out var items);
|
||||
return items as IShellItemArray;
|
||||
var shellViewObject = shellBrowser.QueryActiveShellView();
|
||||
var shellView = shellViewObject as IFolderView;
|
||||
if (shellView != null)
|
||||
{
|
||||
var selectionFlag = onlySelectedFiles ? (uint)_SVGIO.SVGIO_SELECTION : (uint)_SVGIO.SVGIO_ALLVIEW;
|
||||
shellView.ItemCount(selectionFlag, out var countItems);
|
||||
if (countItems > 0)
|
||||
{
|
||||
shellView.Items(selectionFlag, typeof(IShellItemArray).GUID, out var items);
|
||||
return items as IShellItemArray;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user