[SHELL32]
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Thu, 10 Nov 2016 08:05:13 +0000 (08:05 +0000)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Thu, 10 Nov 2016 08:05:13 +0000 (08:05 +0000)
- Make some checks for failure in CDefView and CDefaultContextMenu noisy.

svn path=/trunk/; revision=73187

reactos/dll/win32/shell32/CDefView.cpp
reactos/dll/win32/shell32/CDefaultContextMenu.cpp
reactos/dll/win32/shell32/folders/CPrinterFolder.cpp

index 220aea3..d208057 100644 (file)
@@ -1212,7 +1212,11 @@ HRESULT CDefView::InvokeContextMenuCommand(UINT uCommand)
     if (GetKeyState(VK_CONTROL) & 0x8000)
         cmi.fMask |= CMIC_MASK_CONTROL_DOWN;
 
-    return m_pCM->InvokeCommand(&cmi);
+    HRESULT hr = m_pCM->InvokeCommand(&cmi);
+    if (FAILED_UNEXPECTEDLY(hr))
+        return hr;
+
+    return S_OK;
 }
 
 /**********************************************************
@@ -1237,13 +1241,13 @@ HRESULT CDefView::OpenSelectedItems()
         return E_FAIL;
 
     hResult = GetItemObject(SVGIO_SELECTION, IID_PPV_ARG(IContextMenu, &m_pCM));
-    if (FAILED(hResult))
+    if (FAILED_UNEXPECTEDLY(hResult))
         goto cleanup;
 
     IUnknown_SetSite(m_pCM, (IShellView *)this);
 
     hResult = m_pCM->QueryContextMenu(hMenu, 0, 0x20, 0x7fff, CMF_DEFAULTONLY);
-    if (FAILED(hResult))
+    if (FAILED_UNEXPECTEDLY(hResult))
         goto cleanup;
 
     uCommand = GetMenuDefaultItem(hMenu, FALSE, 0);
@@ -1290,13 +1294,13 @@ LRESULT CDefView::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b
     m_cidl = m_ListView.GetSelectedCount();
 
     hResult = GetItemObject( m_cidl ? SVGIO_SELECTION : SVGIO_BACKGROUND, IID_PPV_ARG(IContextMenu, &m_pCM));
-    if (FAILEDhResult))
+    if (FAILED_UNEXPECTEDLY(hResult))
         goto cleanup;
 
     IUnknown_SetSite(m_pCM, (IShellView *)this);
 
     hResult = m_pCM->QueryContextMenu(m_hContextMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, CMF_NORMAL);
-    if (FAILEDhResult))
+    if (FAILED_UNEXPECTEDLY(hResult))
         goto cleanup;
 
     uCommand = TrackPopupMenu(m_hContextMenu,
@@ -1336,13 +1340,13 @@ LRESULT CDefView::OnExplorerCommand(UINT uCommand, BOOL bUseSelection)
         return 0;
 
     hResult = GetItemObject( bUseSelection ? SVGIO_SELECTION : SVGIO_BACKGROUND, IID_PPV_ARG(IContextMenu, &m_pCM));
-    if (FAILED( hResult))
+    if (FAILED_UNEXPECTEDLY( hResult))
         goto cleanup;
 
     IUnknown_SetSite(m_pCM, (IShellView *)this);
 
     hResult = m_pCM->QueryContextMenu(hMenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST, CMF_NORMAL);
-    if (FAILED( hResult))
+    if (FAILED_UNEXPECTEDLY( hResult))
         goto cleanup;
 
     InvokeContextMenuCommand(uCommand);
@@ -1688,11 +1692,8 @@ LRESULT CDefView::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandl
                 if (m_pSF2Parent)
                 {
                     SHELLDETAILS sd;
-                    if (FAILED(m_pSF2Parent->GetDetailsOf(pidl, lpdi->item.iSubItem, &sd)))
-                    {
-                        FIXME("failed to get details\n");
+                    if (FAILED_UNEXPECTEDLY(m_pSF2Parent->GetDetailsOf(pidl, lpdi->item.iSubItem, &sd)))
                         break;
-                    }
 
                     if (lpnmh->code == LVN_GETDISPINFOA)
                     {
@@ -2228,7 +2229,7 @@ HRESULT WINAPI CDefView::GetItemObject(UINT uItem, REFIID riid, LPVOID *ppvOut)
 
                 IContextMenu* pcm;
                 hr = CDefFolderMenu_Create2(NULL, NULL, 0, NULL, m_pSFParent, NULL, 0, NULL, &pcm);
-                if (FAILED(hr))
+                if (FAILED_UNEXPECTEDLY(hr))
                     return hr;
                 *ppvOut = pcm;
             }
@@ -2238,9 +2239,7 @@ HRESULT WINAPI CDefView::GetItemObject(UINT uItem, REFIID riid, LPVOID *ppvOut)
                 {
                     hr = CDefViewDual_Constructor(riid, (LPVOID*)&m_pShellFolderViewDual);
                     if (FAILED_UNEXPECTEDLY(hr))
-                    {
                         return hr;
-                    }
                 }
                 hr = m_pShellFolderViewDual->QueryInterface(riid, ppvOut);
             }
@@ -2249,6 +2248,8 @@ HRESULT WINAPI CDefView::GetItemObject(UINT uItem, REFIID riid, LPVOID *ppvOut)
         case SVGIO_SELECTION:
             GetSelections();
             hr = m_pSFParent->GetUIObjectOf(m_hWnd, m_cidl, m_apidl, riid, 0, ppvOut);
+            if (FAILED_UNEXPECTEDLY(hr))
+                return hr;
             break;
     }
 
index 7e58744..46d71c8 100644 (file)
@@ -360,9 +360,7 @@ CDefaultContextMenu::LoadDynamicContextMenuHandler(HKEY hKey, const CLSID *pclsi
 
     PDynamicShellEntry pEntry = (DynamicShellEntry *)HeapAlloc(GetProcessHeap(), 0, sizeof(DynamicShellEntry));
     if (!pEntry)
-    {
         return E_OUTOFMEMORY;
-    }
 
     pEntry->iIdCmdFirst = 0;
     pEntry->pNext = NULL;
@@ -829,7 +827,11 @@ HRESULT CDefaultContextMenu::DoRefresh(LPCMINVOKECOMMANDINFO lpcmi)
     if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
-    return psv->Refresh();
+    hr = psv->Refresh();
+    if (FAILED_UNEXPECTEDLY(hr))
+        return hr;
+
+    return S_OK;
 }
 
 HRESULT CDefaultContextMenu::DoPaste(LPCMINVOKECOMMANDINFO lpcmi, BOOL bLink)
@@ -932,7 +934,11 @@ HRESULT CDefaultContextMenu::DoCopyOrCut(LPCMINVOKECOMMANDINFO lpcmi, BOOL bCopy
         m_pDataObj->SetData(&formatetc, &medium, TRUE);
     }
 
-    return OleSetClipboard(m_pDataObj);
+    HRESULT hr = OleSetClipboard(m_pDataObj);
+    if (FAILED_UNEXPECTEDLY(hr))
+        return hr;
+
+    return S_OK;
 }
 
 HRESULT CDefaultContextMenu::DoRename(LPCMINVOKECOMMANDINFO lpcmi)
@@ -954,7 +960,10 @@ HRESULT CDefaultContextMenu::DoRename(LPCMINVOKECOMMANDINFO lpcmi)
         return hr;
 
     SVSIF selFlags = SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE | SVSI_FOCUSED | SVSI_SELECT;
-    lpSV->SelectItem(m_apidl[0], selFlags);
+    hr = lpSV->SelectItem(m_apidl[0], selFlags);
+    if (FAILED_UNEXPECTEDLY(hr))
+        return hr;
+
     return S_OK;
 }
 
@@ -1115,10 +1124,12 @@ CDefaultContextMenu::DoCreateNewFolder(
 
     hr = psv->SelectItem(pidlNewItem, SVSI_DESELECTOTHERS | SVSI_EDIT | SVSI_ENSUREVISIBLE |
                           SVSI_FOCUSED | SVSI_SELECT);
+    if (FAILED_UNEXPECTEDLY(hr))
+        return hr;
 
     SHFree(pidl);
 
-    return hr;
+    return S_OK;
 }
 
 PDynamicShellEntry CDefaultContextMenu::GetDynamicEntry(UINT idCmd)
@@ -1216,7 +1227,7 @@ CDefaultContextMenu::BrowserFlagsFromVerb(LPCMINVOKECOMMANDINFO lpcmi, PStaticSh
 
     /* Try to get the flag from the verb */
     hr = StringCbPrintfW(wszKey, sizeof(wszKey), L"shell\\%s", pEntry->szVerb);
-    if (!SUCCEEDED(hr))
+    if (FAILED_UNEXPECTEDLY(hr))
         return 0;
 
     cbVerb = sizeof(wFlags);
@@ -1650,7 +1661,11 @@ SHCreateDefaultContextMenu(const DEFCONTEXTMENU *pdcm, REFIID riid, void **ppv)
     if (!pdcm->aKeys && pdcm->cidl)
         HackFillKeys((DEFCONTEXTMENU *)pdcm, hkeyHack);
 
-    return CDefaultContextMenu_CreateInstance(pdcm, riid, ppv);
+    HRESULT hr = CDefaultContextMenu_CreateInstance(pdcm, riid, ppv);
+    if (FAILED_UNEXPECTEDLY(hr))
+        return hr;
+
+    return S_OK;
 }
 
 /*************************************************************************
@@ -1683,6 +1698,8 @@ CDefFolderMenu_Create2(
     pdcm.aKeys = ahkeyClsKeys;
 
     HRESULT hr = SHCreateDefaultContextMenu(&pdcm, IID_PPV_ARG(IContextMenu, ppcm));
-    return hr;
-}
+    if (FAILED_UNEXPECTEDLY(hr))
+        return hr;
 
+    return S_OK;
+}
index 5ca3fce..c7df54f 100644 (file)
@@ -54,8 +54,8 @@ HRESULT WINAPI CPrintersExtractIconW_CreateInstane(LPCITEMIDLIST pidl, REFIID ri
 {
     CComPtr<IDefaultExtractIconInit> initIcon;
     HRESULT hr = SHCreateDefaultExtractIcon(IID_PPV_ARG(IDefaultExtractIconInit,&initIcon));
-    if (FAILED(hr))
-        return NULL;
+    if (FAILED_UNEXPECTEDLY(hr))
+        return hr;
 
     /* FIXME: other icons for default, network, print to file */
     initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_PRINTER);