From dc1da96ab82cdcf008301e20d13a6e0cdf8ccf8b Mon Sep 17 00:00:00 2001 From: David Quintana Date: Tue, 28 Oct 2014 01:27:02 +0000 Subject: [PATCH] [RSHELL] * Fix some small things that were getting in the way of fixing the start menu (which was broken and no one noticed). The actual fix will come tomorrow since my brain is about to implode at this time. svn path=/branches/shell-experiments/; revision=65065 --- base/shell/rshell/CMenuBand.cpp | 2 ++ base/shell/rshell/CMenuDeskBar.cpp | 16 +++++++++--- base/shell/rshell/CMenuFocusManager.cpp | 10 ++++++++ base/shell/rshell/precomp.h | 5 ++++ include/reactos/undocshell.h | 34 +++++++++++++++---------- 5 files changed, 49 insertions(+), 18 deletions(-) diff --git a/base/shell/rshell/CMenuBand.cpp b/base/shell/rshell/CMenuBand.cpp index fbb9ba4095f..108d943af16 100644 --- a/base/shell/rshell/CMenuBand.cpp +++ b/base/shell/rshell/CMenuBand.cpp @@ -909,6 +909,7 @@ HRESULT CMenuBand::_KeyboardItemChange(DWORD change) HRESULT CMenuBand::_MenuItemHotTrack(DWORD changeType) { + CComPtr safeThis = this; HRESULT hr; if (m_dwFlags & SMINIT_VERTICAL) @@ -951,6 +952,7 @@ HRESULT CMenuBand::_MenuItemHotTrack(DWORD changeType) { m_subMenuParent->OnSelect(changeType); } + TRACE("Menu closed, executing item...\n"); m_hotBar->ExecuteItem(m_hotItem); break; diff --git a/base/shell/rshell/CMenuDeskBar.cpp b/base/shell/rshell/CMenuDeskBar.cpp index aa0037ca510..1ddc0fc7a73 100644 --- a/base/shell/rshell/CMenuDeskBar.cpp +++ b/base/shell/rshell/CMenuDeskBar.cpp @@ -131,11 +131,15 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::Exec(const GUID *pguidCmdGroup, DWORD nC HRESULT STDMETHODCALLTYPE CMenuDeskBar::QueryService(REFGUID guidService, REFIID riid, void **ppvObject) { + HRESULT hr; + if (IsEqualGUID(guidService, SID_SMenuPopup) || IsEqualGUID(guidService, SID_SMenuBandParent) || IsEqualGUID(guidService, SID_STopLevelBrowser)) { - return this->QueryInterface(riid, ppvObject); + hr = this->QueryInterface(riid, ppvObject); + if (SUCCEEDED(hr)) + return hr; } if (IsEqualGUID(guidService, SID_SMenuBandBottom) || @@ -145,7 +149,9 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::QueryService(REFGUID guidService, REFIID if (m_Client == NULL) return E_NOINTERFACE; - return IUnknown_QueryService(m_Client, guidService, riid, ppvObject); + hr = IUnknown_QueryService(m_Client, guidService, riid, ppvObject); + if (SUCCEEDED(hr)) + return hr; } @@ -484,6 +490,8 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::OnSelect(DWORD dwSelectType) * */ + CComPtr oldParent = m_SubMenuParent; + switch (dwSelectType) { case MPOS_EXECUTE: @@ -498,8 +506,8 @@ HRESULT STDMETHODCALLTYPE CMenuDeskBar::OnSelect(DWORD dwSelectType) case MPOS_SELECTLEFT: case MPOS_SELECTRIGHT: case MPOS_CHILDTRACKING: - if (m_SubMenuParent) - return m_SubMenuParent->OnSelect(dwSelectType); + if (oldParent) + return oldParent->OnSelect(dwSelectType); break; } diff --git a/base/shell/rshell/CMenuFocusManager.cpp b/base/shell/rshell/CMenuFocusManager.cpp index f4e758e5dce..598a112cca5 100644 --- a/base/shell/rshell/CMenuFocusManager.cpp +++ b/base/shell/rshell/CMenuFocusManager.cpp @@ -832,6 +832,11 @@ HRESULT CMenuFocusManager::PopMenuBar(CMenuBand * mb) DbgPrint("PopMenuBar %p\n", mb); + if (m_current == m_entryUnderMouse) + { + m_entryUnderMouse = NULL; + } + hr = PopFromArray(&type, &mbc, NULL); if (FAILED_UNEXPECTEDLY(hr)) { @@ -871,6 +876,11 @@ HRESULT CMenuFocusManager::PopMenuPopup(CMenuBand * mb) DbgPrint("PopMenuPopup %p\n", mb); + if (m_current == m_entryUnderMouse) + { + m_entryUnderMouse = NULL; + } + hr = PopFromArray(&type, &mbc, NULL); if (FAILED_UNEXPECTEDLY(hr)) { diff --git a/base/shell/rshell/precomp.h b/base/shell/rshell/precomp.h index d5fb9d675a4..9b23dbe2c0b 100644 --- a/base/shell/rshell/precomp.h +++ b/base/shell/rshell/precomp.h @@ -37,6 +37,11 @@ #define COBJMACROS +//#define DEBUG_CCOMOBJECT +//#define DEBUG_CCOMOBJECT_CREATION 1 +//#define DEBUG_CCOMOBJECT_DESTRUCTION 1 +//#define DEBUG_CCOMOBJECT_REFCOUNTING 0 + #include #include #include diff --git a/include/reactos/undocshell.h b/include/reactos/undocshell.h index 517b00bcf5a..426efea0bc2 100644 --- a/include/reactos/undocshell.h +++ b/include/reactos/undocshell.h @@ -626,6 +626,9 @@ class CComDebugObject : public Base public: CComDebugObject(void * = NULL) { +#if DEBUG_CCOMOBJECT_CREATION + DbgPrint("%S, this=%08p\n", __FUNCTION__, static_cast(this)); +#endif _pAtlModule->Lock(); } @@ -638,25 +641,28 @@ public: STDMETHOD_(ULONG, AddRef)() { int rc = this->InternalAddRef(); - DbgPrint("RefCount is now %d(++)! %s\n", rc, __FUNCTION__); +#if DEBUG_CCOMOBJECT_REFCOUNTING + DbgPrint("%s, RefCount is now %d(--)! \n", __FUNCTION__, rc); +#endif return rc; } STDMETHOD_(ULONG, Release)() { - ULONG newRefCount; + int rc = this->InternalRelease(); - newRefCount = this->InternalRelease(); - if (newRefCount == 0) +#if DEBUG_CCOMOBJECT_REFCOUNTING + DbgPrint("%s, RefCount is now %d(--)! \n", __FUNCTION__, rc); +#endif + + if (rc == 0) { - DbgPrint("RefCount is now 0! Deleting! %s\n", newRefCount, __FUNCTION__); +#if DEBUG_CCOMOBJECT_DESTRUCTION + DbgPrint("%s, RefCount reached 0 Deleting!\n", __FUNCTION__); +#endif delete this; } - else - { - DbgPrint("RefCount is now %d(--)! %s\n", newRefCount, __FUNCTION__); - } - return newRefCount; + return rc; } STDMETHOD(QueryInterface)(REFIID iid, void **ppvObject) @@ -675,9 +681,9 @@ public: hResult = E_OUTOFMEMORY; newInstance = NULL; - ATLTRY(newInstance = new CComDebugObject()) - if (newInstance != NULL) - { + ATLTRY(newInstance = new CComDebugObject()); + if (newInstance != NULL) + { newInstance->SetVoid(NULL); newInstance->InternalFinalConstructAddRef(); hResult = newInstance->_AtlInitialConstruct(); @@ -691,7 +697,7 @@ public: delete newInstance; newInstance = NULL; } - } + } *pp = newInstance; return hResult; }