Author: dquintana
Date: Mon Oct 20 21:35:22 2014
New Revision: 64858
URL:
http://svn.reactos.org/svn/reactos?rev=64858&view=rev
Log:
[BROWSEUI]
* SHOnCWMCommandLine: Fix IETHREADPARAM leak.
[SHELL32]
* Fix HMENU leak of the popup used in the view mode button of the toolbar.
[RSHELL]
* Undo a previous change to help debug the leaks.
* Remove child submenus when closing a menu band.
* Add some extra verification for debugging purposes.
[BROWSEUI]
[RSHELL]
[SHELL32]
* Move ReleaseCComPtrExpectZero to the shared header.
Modified:
branches/shell-experiments/base/shell/rshell/CMenuBand.cpp
branches/shell-experiments/base/shell/rshell/CMenuBand.h
branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp
branches/shell-experiments/base/shell/rshell/CStartMenu.cpp
branches/shell-experiments/dll/win32/browseui/desktopipc.cpp
branches/shell-experiments/dll/win32/browseui/internettoolbar.cpp
branches/shell-experiments/dll/win32/browseui/shellbrowser.cpp
branches/shell-experiments/dll/win32/shell32/shlview.cpp
branches/shell-experiments/include/reactos/undocshell.h
Modified: branches/shell-experiments/base/shell/rshell/CMenuBand.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuBand.cpp [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/CMenuBand.cpp [iso-8859-1] Mon Oct 20
21:35:22 2014
@@ -56,7 +56,9 @@
m_popupBar(NULL),
m_popupItem(-1),
m_Show(FALSE),
- m_shellBottom(FALSE)
+ m_shellBottom(FALSE),
+ m_trackedPopup(NULL),
+ m_trackedHwnd(NULL)
{
m_focusManager = CMenuFocusManager::AcquireManager();
}
@@ -418,6 +420,16 @@
HRESULT STDMETHODCALLTYPE CMenuBand::CloseDW(DWORD dwReserved)
{
+ if (m_subMenuChild)
+ {
+ m_subMenuChild->OnSelect(MPOS_CANCELLEVEL);
+ }
+
+ if (m_subMenuChild)
+ {
+ DbgPrint("Child object should have removed itself.\n");
+ }
+
ShowDW(FALSE);
if (m_staticToolbar != NULL)
@@ -594,7 +606,10 @@
HRESULT STDMETHODCALLTYPE CMenuBand::SetClient(IUnknown *punkClient)
{
- m_subMenuChild = NULL;
+ if (m_subMenuChild)
+ {
+ ReleaseCComPtrExpectZero(m_subMenuChild);
+ }
if (!punkClient)
{
@@ -738,9 +753,15 @@
UINT flags = TPM_VERPOSANIMATION | TPM_VERTICAL | TPM_LEFTALIGN;
HWND hwnd = m_menuOwner ? m_menuOwner : m_topLevelWindow;
+ m_trackedPopup = popup;
+ m_trackedHwnd = hwnd;
+
m_focusManager->PushTrackedPopup(popup);
::TrackPopupMenuEx(popup, flags, x, y, hwnd, ¶ms);
m_focusManager->PopTrackedPopup(popup);
+
+ m_trackedPopup = NULL;
+ m_trackedHwnd = NULL;
_DisableMouseTrack(FALSE);
@@ -950,11 +971,19 @@
HRESULT CMenuBand::_CancelCurrentPopup()
{
- if (!m_subMenuChild)
- return S_FALSE;
-
- HRESULT hr = m_subMenuChild->OnSelect(MPOS_CANCELLEVEL);
- return hr;
+ if (m_subMenuChild)
+ {
+ HRESULT hr = m_subMenuChild->OnSelect(MPOS_CANCELLEVEL);
+ return hr;
+ }
+
+ if (m_trackedPopup)
+ {
+ ::SendMessage(m_trackedHwnd, WM_CANCELMODE, 0, 0);
+ return S_OK;
+ }
+
+ return S_FALSE;
}
HRESULT CMenuBand::_OnPopupSubMenu(IShellMenu * childShellMenu, POINTL * pAt, RECTL *
pExclude, BOOL keyInitiated)
@@ -1044,6 +1073,11 @@
return S_OK;
}
+HRESULT CMenuBand::_HasSubMenu()
+{
+ return m_popupBar ? S_OK : S_FALSE;
+}
+
HRESULT STDMETHODCALLTYPE CMenuBand::InvalidateItem(LPSMDATA psmd, DWORD dwFlags)
{
UNIMPLEMENTED;
Modified: branches/shell-experiments/base/shell/rshell/CMenuBand.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuBand.h [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/CMenuBand.h [iso-8859-1] Mon Oct 20
21:35:22 2014
@@ -68,6 +68,9 @@
BOOL m_Show;
BOOL m_shellBottom;
+ HMENU m_trackedPopup;
+ HWND m_trackedHwnd;
+
public:
CMenuBand();
virtual ~CMenuBand();
@@ -194,6 +197,7 @@
HRESULT _KillPopupTimers();
HRESULT _MenuBarMouseDown(HWND hwnd, INT item);
HRESULT _MenuBarMouseUp(HWND hwnd, INT item);
+ HRESULT _HasSubMenu();
BOOL UseBigIcons()
{
Modified: branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp [iso-8859-1] Mon Oct 20
21:35:22 2014
@@ -171,7 +171,17 @@
CComPtr<IDeskBarClient> pDeskBandClient;
HRESULT hr;
- m_Client.Release();
+ if (m_Client)
+ {
+ hr = m_Client->QueryInterface(IID_PPV_ARG(IDeskBarClient,
&pDeskBandClient));
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ pDeskBandClient->SetDeskBarSite(NULL);
+
+ pDeskBandClient = NULL;
+ m_Client = NULL;
+ }
if (punkClient == NULL)
return S_OK;
@@ -222,9 +232,19 @@
if (m_Shown)
_CloseBar();
+ m_SubMenuParent = NULL;
+
m_Site = pUnkSite;
- IUnknown_QueryService(m_Site, SID_SMenuPopup, IID_PPV_ARG(IMenuPopup,
&m_SubMenuParent));
+ if (m_Site)
+ {
+ IUnknown_QueryService(m_Site, SID_SMenuPopup, IID_PPV_ARG(IMenuPopup,
&m_SubMenuParent));
+ }
+ else
+ {
+ DestroyWindow();
+ SetClient(NULL);
+ }
return S_OK;
}
Modified: branches/shell-experiments/base/shell/rshell/CStartMenu.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CStartMenu.cpp [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/CStartMenu.cpp [iso-8859-1] Mon Oct 20
21:35:22 2014
@@ -151,7 +151,14 @@
int csidl = 0;
IShellMenu *pShellMenu;
+#if USE_SYSTEM_MENUBAND
+ hr = CoCreateInstance(CLSID_MenuBand,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_PPV_ARG(IShellMenu, &pShellMenu));
+#else
hr = CMenuBand_Constructor(IID_PPV_ARG(IShellMenu, &pShellMenu));
+#endif
if (FAILED_UNEXPECTEDLY(hr))
return hr;
@@ -394,15 +401,36 @@
LPITEMIDLIST pidlPrograms;
CComPtr<IShellFolder> psfPrograms;
+#if USE_SYSTEM_MENUBAND
+ hr = CoCreateInstance(CLSID_MenuBand,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_PPV_ARG(IShellMenu, &pShellMenu));
+#else
hr = CMenuBand_Constructor(IID_PPV_ARG(IShellMenu, &pShellMenu));
- if (FAILED_UNEXPECTEDLY(hr))
- return hr;
-
+#endif
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+#if USE_SYSTEM_MENUSITE
+ hr = CoCreateInstance(CLSID_MenuBandSite,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_PPV_ARG(IBandSite, &pBandSite));
+#else
hr = CMenuSite_Constructor(IID_PPV_ARG(IBandSite, &pBandSite));
- if (FAILED_UNEXPECTEDLY(hr))
- return hr;
-
+#endif
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+#if USE_SYSTEM_MENUDESKBAR
+ hr = CoCreateInstance(CLSID_MenuDeskBar,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_PPV_ARG(IDeskBar, &pDeskBar));
+#else
hr = CMenuDeskBar_Constructor(IID_PPV_ARG(IDeskBar, &pDeskBar));
+#endif
if (FAILED_UNEXPECTEDLY(hr))
return hr;
Modified: branches/shell-experiments/dll/win32/browseui/desktopipc.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/bro…
==============================================================================
--- branches/shell-experiments/dll/win32/browseui/desktopipc.cpp [iso-8859-1] (original)
+++ branches/shell-experiments/dll/win32/browseui/desktopipc.cpp [iso-8859-1] Mon Oct 20
21:35:22 2014
@@ -345,22 +345,6 @@
return params;
}
-
-/*************************************************************************
-* SHOnCWMCommandLine [BROWSEUI.127]
-*/
-extern "C" BOOL WINAPI SHOnCWMCommandLine(HANDLE hSharedInfo)
-{
- DbgPrint("SHOnCWMCommandLine\n");
-
- PIE_THREAD_PARAM_BLOCK params = ParseSharedPacket(hSharedInfo);
-
- if (params)
- return SHOpenFolderWindow(params);
-
- return FALSE;
-}
-
/*************************************************************************
* SHCreateIETHREADPARAM [BROWSEUI.123]
*/
@@ -442,6 +426,23 @@
}
/*************************************************************************
+* SHOnCWMCommandLine [BROWSEUI.127]
+*/
+extern "C" BOOL WINAPI SHOnCWMCommandLine(HANDLE hSharedInfo)
+{
+ DbgPrint("SHOnCWMCommandLine\n");
+
+ PIE_THREAD_PARAM_BLOCK params = ParseSharedPacket(hSharedInfo);
+
+ if (params)
+ return SHOpenFolderWindow(params);
+
+ SHDestroyIETHREADPARAM(params);
+
+ return FALSE;
+}
+
+/*************************************************************************
* SHOpenFolderWindow [BROWSEUI.102]
* see SHOpenNewFrame below for remarks
*/
Modified: branches/shell-experiments/dll/win32/browseui/internettoolbar.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/bro…
==============================================================================
--- branches/shell-experiments/dll/win32/browseui/internettoolbar.cpp [iso-8859-1]
(original)
+++ branches/shell-experiments/dll/win32/browseui/internettoolbar.cpp [iso-8859-1] Mon Oct
20 21:35:22 2014
@@ -992,27 +992,6 @@
return hResult;
}
return S_OK;
-}
-
-template<class T>
-void ReleaseCComPtrExpectZero(CComPtr<T>& cptr, BOOL forceRelease = FALSE)
-{
- if (cptr.p != NULL)
- {
- int nrc = cptr->Release();
- if (nrc > 0)
- {
- DbgPrint("WARNING: Unexpected RefCount > 0 (%d)!\n", nrc);
- if (forceRelease)
- {
- while (nrc > 0)
- {
- nrc = cptr->Release();
- }
- }
- }
- cptr.Detach();
- }
}
HRESULT STDMETHODCALLTYPE CInternetToolbar::CloseDW(DWORD dwReserved)
Modified: branches/shell-experiments/dll/win32/browseui/shellbrowser.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/bro…
==============================================================================
--- branches/shell-experiments/dll/win32/browseui/shellbrowser.cpp [iso-8859-1]
(original)
+++ branches/shell-experiments/dll/win32/browseui/shellbrowser.cpp [iso-8859-1] Mon Oct 20
21:35:22 2014
@@ -2563,6 +2563,9 @@
return S_OK;
}
+ if (!fCurrentShellView)
+ return S_FALSE;
+
return fCurrentShellView->TranslateAcceleratorW(pmsg);
}
@@ -3068,27 +3071,6 @@
{
OnCreate(reinterpret_cast<LPCREATESTRUCT> (lParam));
return 0;
-}
-
-template<class T>
-void ReleaseCComPtrExpectZero(CComPtr<T>& cptr, BOOL forceRelease = FALSE)
-{
- if (cptr.p != NULL)
- {
- int nrc = cptr->Release();
- if (nrc > 0)
- {
- DbgPrint("WARNING: Unexpected RefCount > 0!\n");
- if (forceRelease)
- {
- while (nrc > 0)
- {
- nrc = cptr->Release();
- }
- }
- }
- cptr.Detach();
- }
}
LRESULT CShellBrowser::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
&bHandled)
Modified: branches/shell-experiments/dll/win32/shell32/shlview.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/she…
==============================================================================
--- branches/shell-experiments/dll/win32/shell32/shlview.cpp [iso-8859-1] (original)
+++ branches/shell-experiments/dll/win32/shell32/shlview.cpp [iso-8859-1] Mon Oct 20
21:35:22 2014
@@ -341,36 +341,37 @@
typedef void (CALLBACK *PFNSHGETSETTINGSPROC)(LPSHELLFLAGSTATE lpsfs, DWORD dwMask);
-CDefView::CDefView()
-{
- m_hWndList = NULL;
- m_hWndParent = NULL;
- m_FolderSettings.fFlags = 0;
- m_FolderSettings.ViewMode = 0;
- m_hMenu = NULL;
- m_menusLoaded = FALSE;
- m_uState = 0;
- m_cidl = 0;
- m_apidl = NULL;
- m_sortInfo.bIsAscending = FALSE;
- m_sortInfo.nHeaderID = 0;
- m_sortInfo.nLastHeaderID = 0;
- m_hNotify = 0;
- m_hAccel = NULL;
- m_dwAspects = 0;
- m_dwAdvf = 0;
- m_iDragOverItem = 0;
- m_cScrollDelay = 0;
- m_ptLastMousePos.x = 0;
- m_ptLastMousePos.y = 0;
- m_isEditing = FALSE;
- ZeroMemory(&m_Category, sizeof(m_Category));
- m_hView = NULL;
+CDefView::CDefView() :
+ m_hWndList(NULL),
+ m_hWndParent(NULL),
+ m_hMenu(NULL),
+ m_menusLoaded(FALSE),
+ m_uState(0),
+ m_cidl(0),
+ m_apidl(NULL),
+ m_hNotify(0),
+ m_hAccel(NULL),
+ m_dwAspects(0),
+ m_dwAdvf(0),
+ m_iDragOverItem(0),
+ m_cScrollDelay(0),
+ m_isEditing(FALSE),
+ m_hView(NULL)
+{
+ m_FolderSettings = { 0 };
+ m_sortInfo = { 0 };
+ m_ptLastMousePos = { 0 };
+ m_Category = { 0 };
}
CDefView::~CDefView()
{
TRACE(" destroying IShellView(%p)\n", this);
+
+ if (m_hWnd)
+ {
+ DestroyViewWindow();
+ }
SHFree(m_apidl);
}
@@ -2122,12 +2123,35 @@
/*Make absolutely sure all our UI is cleaned up.*/
UIActivate(SVUIA_DEACTIVATE);
+ if (m_hAccel)
+ {
+ // "Accelerator tables loaded from resources are freed automatically when
the application terminates." -- MSDN
+ m_hAccel = NULL;
+ }
+
+ if (m_hView)
+ {
+ DestroyMenu(m_hView);
+ m_hView = NULL;
+ }
+
if (m_hMenu)
{
DestroyMenu(m_hMenu);
- }
-
- DestroyWindow();
+ m_hView = NULL;
+ }
+
+ if (m_hWndList)
+ {
+ ::DestroyWindow(m_hWndList);
+ m_hWndList = NULL;
+ }
+
+ if (m_hWnd)
+ {
+ DestroyWindow();
+ }
+
m_pShellBrowser.Release();
m_pCommDlgBrowser.Release();
Modified: branches/shell-experiments/include/reactos/undocshell.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/include/react…
==============================================================================
--- branches/shell-experiments/include/reactos/undocshell.h [iso-8859-1] (original)
+++ branches/shell-experiments/include/reactos/undocshell.h [iso-8859-1] Mon Oct 20
21:35:22 2014
@@ -691,6 +691,27 @@
}
};
+template<class T>
+void ReleaseCComPtrExpectZero(CComPtr<T>& cptr, BOOL forceRelease = FALSE)
+{
+ if (cptr.p != NULL)
+ {
+ int nrc = cptr->Release();
+ if (nrc > 0)
+ {
+ DbgPrint("WARNING: Unexpected RefCount > 0 (%d)!\n", nrc);
+ if (forceRelease)
+ {
+ while (nrc > 0)
+ {
+ nrc = cptr->Release();
+ }
+ }
+ }
+ cptr.Detach();
+ }
+}
+
template<class T, class R>
HRESULT inline ShellObjectCreator(REFIID riid, R ** ppv)
{