mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 03:07:56 +01:00
[ImageResizer]Fix silent context menu crash (#22503)
This commit is contained in:
@@ -79,6 +79,12 @@ public:
|
||||
|
||||
IFACEMETHODIMP GetState(_In_opt_ IShellItemArray* selection, _In_ BOOL okToBeSlow, _Out_ EXPCMDSTATE* cmdState)
|
||||
{
|
||||
if (nullptr == selection) {
|
||||
// We've observed that it's possible that a null gets passed instead of an empty array. Just don't show the context menu in this case.
|
||||
*cmdState = ECS_HIDDEN;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (!CSettingsInstance().GetEnabled())
|
||||
{
|
||||
*cmdState = ECS_HIDDEN;
|
||||
@@ -90,9 +96,14 @@ public:
|
||||
#pragma warning(suppress : 26812)
|
||||
PERCEIVED type;
|
||||
PERCEIVEDFLAG flag;
|
||||
IShellItem* shellItem;
|
||||
IShellItem* shellItem=nullptr;
|
||||
//Check extension of first item in the list (the item which is right-clicked on)
|
||||
selection->GetItemAt(0, &shellItem);
|
||||
HRESULT getItemResult = selection->GetItemAt(0, &shellItem);
|
||||
if (S_OK != getItemResult || nullptr == shellItem) {
|
||||
// Some safeguards to avoid runtime errors.
|
||||
*cmdState = ECS_HIDDEN;
|
||||
return S_OK;
|
||||
}
|
||||
LPTSTR pszPath;
|
||||
// Retrieves the entire file system path of the file from its shell item
|
||||
shellItem->GetDisplayName(SIGDN_FILESYSPATH, &pszPath);
|
||||
|
||||
Reference in New Issue
Block a user