[SHELL32] Bypass OpenWith for Delete and F2 (Rename) Keys (#4032) CORE-17810
authorDoug Lyons <douglyons@douglyons.com>
Thu, 14 Oct 2021 21:03:53 +0000 (16:03 -0500)
committerGitHub <noreply@github.com>
Thu, 14 Oct 2021 21:03:53 +0000 (23:03 +0200)
Logspam started during 0.4.9-dev'ing when zipfldr got committed, logspam became much worse by
0.4.10-dev-599-g 932df378bf35146a56c796bec36c5c689109fbd6
But the actual bug of 'calling those functions when not needed' is much older than that.

I do intend to port this improvement back into older rls-branches.

dll/win32/shell32/CDefView.cpp

index 00e3103..1a15523 100644 (file)
@@ -1573,19 +1573,21 @@ cleanup:
 LRESULT CDefView::OnExplorerCommand(UINT uCommand, BOOL bUseSelection)
 {
     HRESULT hResult;
-    HMENU hMenu;
-
-    hMenu = CreatePopupMenu();
-    if (!hMenu)
-        return 0;
+    HMENU hMenu = NULL;
 
     hResult = GetItemObject( bUseSelection ? SVGIO_SELECTION : SVGIO_BACKGROUND, IID_PPV_ARG(IContextMenu, &m_pCM));
     if (FAILED_UNEXPECTEDLY( hResult))
         goto cleanup;
+    if ((uCommand != FCIDM_SHVIEW_DELETE) && (uCommand != FCIDM_SHVIEW_RENAME))
+    {
+        hMenu = CreatePopupMenu();
+        if (!hMenu)
+            return 0;
 
-    hResult = m_pCM->QueryContextMenu(hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, CMF_NORMAL);
-    if (FAILED_UNEXPECTEDLY( hResult))
-        goto cleanup;
+        hResult = m_pCM->QueryContextMenu(hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, CMF_NORMAL);
+        if (FAILED_UNEXPECTEDLY(hResult))
+            goto cleanup;
+    }
 
     if (bUseSelection)
     {