Reactos

[EXPLORER][BROWSEUI][SHELL32][NETSHELL] Fix wrong usage of CComPtr

+23 -41
+1 -4
base/shell/explorer/startctxmnu.cpp
··· 242 242 243 243 HRESULT CStartMenuBtnCtxMenu_CreateInstance(ITrayWindow * m_TrayWnd, IN HWND m_Owner, IContextMenu ** ppCtxMenu) 244 244 { 245 - CStartMenuBtnCtxMenu * mnu = new CComObject<CStartMenuBtnCtxMenu>(); 246 - mnu->Initialize(m_TrayWnd, m_Owner); 247 - *ppCtxMenu = mnu; 248 - return S_OK; 245 + return ShellObjectCreatorInit<CStartMenuBtnCtxMenu>(m_TrayWnd, m_Owner, IID_PPV_ARG(IContextMenu, ppCtxMenu)); 249 246 }
+1 -1
base/shell/explorer/tbsite.cpp
··· 301 301 302 302 if (ppcm != NULL) 303 303 { 304 - m_ContextMenu->AddRef(); 305 304 *ppcm = m_ContextMenu; 305 + (*ppcm)->AddRef(); 306 306 } 307 307 308 308 /* Add the menu items */
-1
base/shell/explorer/traywnd.cpp
··· 2943 2943 { 2944 2944 CComPtr<IContextMenu> ctxMenu; 2945 2945 CStartMenuBtnCtxMenu_CreateInstance(this, m_hWnd, &ctxMenu); 2946 - ctxMenu->AddRef(); 2947 2946 TrackCtxMenu(ctxMenu, ppt, hWndExclude, m_Position == ABE_BOTTOM, this); 2948 2947 } 2949 2948 }
+1 -1
dll/shellext/netshell/lanstatusui.cpp
··· 953 953 pItem->uID = Index; 954 954 pItem->pNext = NULL; 955 955 pItem->pNet = pNetCon; 956 - pNetCon->AddRef(); 956 + pItem->pNet->AddRef(); 957 957 hwndDlg = CreateDialogParamW(netshell_hInstance, MAKEINTRESOURCEW(IDD_STATUS), NULL, LANStatusDlg, (LPARAM)pContext); 958 958 if (!hwndDlg) 959 959 {
-6
dll/win32/browseui/CAutoComplete.cpp
··· 1126 1126 ::GetWindowRect(m_hwndEdit, &m_rcEdit); 1127 1127 1128 1128 // get an IEnumString 1129 - ATLASSERT(!m_pEnum); 1130 1129 punkACL->QueryInterface(IID_IEnumString, (VOID **)&m_pEnum); 1131 1130 TRACE("m_pEnum: %p\n", static_cast<void *>(m_pEnum)); 1132 - if (m_pEnum) 1133 - m_pEnum->AddRef(); // hold not to be freed 1134 1131 1135 1132 // get an IACList 1136 - ATLASSERT(!m_pACList); 1137 1133 punkACL->QueryInterface(IID_IACList, (VOID **)&m_pACList); 1138 1134 TRACE("m_pACList: %p\n", static_cast<void *>(m_pACList)); 1139 - if (m_pACList) 1140 - m_pACList->AddRef(); // hold not to be freed 1141 1135 1142 1136 UpdateDropDownState(); // create/hide the drop-down window if necessary 1143 1137
+8 -14
dll/win32/browseui/desktopipc.cpp
··· 348 348 BOOL Ret; 349 349 350 350 // Tell the thread ref we are using it. 351 - if (parameters && parameters->offsetF8) 352 - parameters->offsetF8->AddRef(); 351 + if (parameters && parameters->pExplorerInstance) 352 + parameters->pExplorerInstance->AddRef(); 353 353 354 354 /* Handle /e parameter */ 355 355 UINT wFlags = 0; ··· 410 410 } 411 411 } 412 412 413 - int nrc = browser->Release(); 414 - if (nrc > 0) 415 - { 416 - DbgPrint("WARNING: There are %d references to the CShellBrowser active or leaked.\n", nrc); 417 - } 418 - 419 - browser.Detach(); 413 + ReleaseCComPtrExpectZero(browser); 420 414 421 415 // Tell the thread ref we are not using it anymore. 422 - if (parameters && parameters->offsetF8) 423 - parameters->offsetF8->Release(); 416 + if (parameters && parameters->pExplorerInstance) 417 + parameters->pExplorerInstance->Release(); 424 418 425 419 return hResult; 426 420 } ··· 519 513 param->offset78->Release(); 520 514 if (param->offsetC != NULL) 521 515 param->offsetC->Release(); 522 - if (param->offsetF8 != NULL) 523 - param->offsetF8->Release(); 516 + if (param->pExplorerInstance != NULL) 517 + param->pExplorerInstance->Release(); 524 518 LocalFree(param); 525 519 } 526 520 ··· 563 557 564 558 PIE_THREAD_PARAM_BLOCK paramsCopy = SHCloneIETHREADPARAM(parameters); 565 559 566 - SHGetInstanceExplorer(&(paramsCopy->offsetF8)); 560 + SHGetInstanceExplorer(&(paramsCopy->pExplorerInstance)); 567 561 threadHandle = CreateThread(NULL, 0x10000, BrowserThreadProc, paramsCopy, 0, &threadID); 568 562 if (threadHandle != NULL) 569 563 {
-2
dll/win32/browseui/internettoolbar.cpp
··· 614 614 fMenuCallback = new CComObject<CMenuCallback>(); 615 615 fToolbarWindow = NULL; 616 616 fAdviseCookie = 0; 617 - 618 - fMenuCallback->AddRef(); 619 617 } 620 618 621 619 CInternetToolbar::~CInternetToolbar()
+1 -1
dll/win32/browseui/shellbrowser.cpp
··· 1121 1121 1122 1122 // we have to store our basebar into cache now 1123 1123 *cache = newBaseBar; 1124 - newBaseBar->AddRef(); 1124 + (*cache)->AddRef(); 1125 1125 1126 1126 // tell the new base bar about the shell browser 1127 1127 hResult = IUnknown_SetSite(newBaseBar, static_cast<IDropTarget *>(this));
+1 -1
dll/win32/shell32/CFolderItems.cpp
··· 38 38 if (ppid) 39 39 { 40 40 *ppid = m_Folder; 41 - m_Folder->AddRef(); 41 + (*ppid)->AddRef(); 42 42 } 43 43 return E_NOTIMPL; 44 44 }
+2 -2
dll/win32/shell32/shelldesktop/CDesktopBrowser.cpp
··· 321 321 if (ppshv == NULL) 322 322 return E_POINTER; 323 323 *ppshv = m_ShellView; 324 - if (m_ShellView != NULL) 325 - m_ShellView->AddRef(); 324 + if (*ppshv != NULL) 325 + (*ppshv)->AddRef(); 326 326 327 327 return S_OK; 328 328 }
+3 -3
dll/win32/shell32/shellmenu/CMenuBand.cpp
··· 99 99 100 100 if (ppsmc) 101 101 { 102 - if (m_psmc) 103 - m_psmc->AddRef(); 104 102 *ppsmc = m_psmc; 103 + if (*ppsmc) 104 + (*ppsmc)->AddRef(); 105 105 } 106 106 107 107 if (puId) ··· 655 655 656 656 if (m_subMenuChild) 657 657 { 658 - m_subMenuChild->AddRef(); 659 658 *ppunkClient = m_subMenuChild; 659 + (*ppunkClient)->AddRef(); 660 660 } 661 661 662 662 return S_OK;
+2 -2
sdk/include/reactos/browseui_undoc.h
··· 60 60 UCHAR gap108[24]; 61 61 DWORD dword120; 62 62 DWORD dword124; 63 - IUnknown* offsetF8; // 0x128 instance explorer 63 + IUnknown* pExplorerInstance; // 0x128 instance explorer 64 64 UCHAR byteflags_130; 65 65 } IE_THREAD_PARAM_BLOCK, * PIE_THREAD_PARAM_BLOCK; 66 66 #else ··· 90 90 char offsetA4[0xD8-0xA4]; // unknown contents -- 0xA4..0xD8 91 91 LONG offsetD8; 92 92 char offsetDC[0xF8-0xDC]; // unknown contents -- 0xDC..0xF8 93 - IUnknown * offsetF8; // instance explorer 93 + IUnknown * pExplorerInstance; // instance explorer 94 94 LONG offsetFC; // unknown contents 95 95 } IE_THREAD_PARAM_BLOCK, *PIE_THREAD_PARAM_BLOCK; 96 96 #endif
+3 -3
sdk/include/reactos/shellutils.h
··· 226 226 { 227 227 if (cptr.p != NULL) 228 228 { 229 - int nrc = cptr->Release(); 229 + T *raw = cptr.Detach(); 230 + int nrc = raw->Release(); 230 231 if (nrc > 0) 231 232 { 232 233 DbgPrint("WARNING: Unexpected RefCount > 0 (%d)!\n", nrc); ··· 234 235 { 235 236 while (nrc > 0) 236 237 { 237 - nrc = cptr->Release(); 238 + nrc = raw->Release(); 238 239 } 239 240 } 240 241 } 241 - cptr.Detach(); 242 242 } 243 243 } 244 244