Author: dquintana
Date: Tue Oct 28 21:40:50 2014
New Revision: 65088
URL:
http://svn.reactos.org/svn/reactos?rev=65088&view=rev
Log:
[RSHELL]
* CMenuBand: Refcount before assigning a return pointer.
* CMenuDeskBar: Revert change and protect the refcounting in case I was wrong to assume
there will be exactly one OnFinalMessage for each OnCreate.
* CMenuToolbars: Add a debug message.
* CStartMenu: Refcount correctly.
Modified:
branches/shell-experiments/base/shell/rshell/CMenuBand.cpp
branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp
branches/shell-experiments/base/shell/rshell/CMenuDeskBar.h
branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp
branches/shell-experiments/base/shell/rshell/CStartMenu.cpp
branches/shell-experiments/base/shell/rshell/precomp.h
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] Tue Oct 28
21:40:50 2014
@@ -628,21 +628,22 @@
return S_OK;
}
- HRESULT hr = punkClient->QueryInterface(IID_PPV_ARG(IMenuPopup,
&m_subMenuChild));
-
- return hr;
+ return punkClient->QueryInterface(IID_PPV_ARG(IMenuPopup, &m_subMenuChild));
}
HRESULT STDMETHODCALLTYPE CMenuBand::GetClient(IUnknown **ppunkClient)
{
// HACK, so I can test for a submenu in the DeskBar
- if (ppunkClient)
- {
- if (m_subMenuChild)
- *ppunkClient = m_subMenuChild;
- else
- *ppunkClient = NULL;
- }
+ if (!ppunkClient)
+ return E_POINTER;
+ *ppunkClient = NULL;
+
+ if (m_subMenuChild)
+ {
+ m_subMenuChild->AddRef();
+ *ppunkClient = m_subMenuChild;
+ }
+
return S_OK;
}
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] Tue Oct 28
21:40:50 2014
@@ -39,7 +39,8 @@
m_IconSize(0),
m_Banner(NULL),
m_Shown(FALSE),
- m_ShowFlags(0)
+ m_ShowFlags(0),
+ m_didAddRef(FALSE)
{
}
@@ -49,7 +50,11 @@
LRESULT CMenuDeskBar::_OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
&bHandled)
{
- this->AddRef();
+ if (!m_didAddRef)
+ {
+ this->AddRef();
+ m_didAddRef = TRUE;
+ }
bHandled = FALSE;
return 0;
@@ -57,6 +62,11 @@
void CMenuDeskBar::OnFinalMessage(HWND /* hWnd */)
{
+ if (m_didAddRef)
+ {
+ this->Release();
+ m_didAddRef = FALSE;
+ }
}
HRESULT STDMETHODCALLTYPE CMenuDeskBar::Initialize(THIS)
Modified: branches/shell-experiments/base/shell/rshell/CMenuDeskBar.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuDeskBar.h [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/CMenuDeskBar.h [iso-8859-1] Tue Oct 28
21:40:50 2014
@@ -49,6 +49,8 @@
BOOL m_Shown;
DWORD m_ShowFlags;
+
+ BOOL m_didAddRef;
virtual void OnFinalMessage(HWND hWnd);
public:
Modified: branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp [iso-8859-1]
(original)
+++ branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp [iso-8859-1] Tue Oct 28
21:40:50 2014
@@ -1374,6 +1374,7 @@
pidl = ILClone(m_idList);
if (!pidl)
{
+ ERR("ILClone failed!\n");
(*reinterpret_cast<IUnknown**>(ppv))->Release();
return E_FAIL;
}
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] Tue Oct 28
21:40:50 2014
@@ -262,16 +262,13 @@
IBandSite* pBandSite,
IDeskBar* pDeskBar)
{
- m_pShellMenu.Attach(pShellMenu);
- m_pBandSite.Attach(pBandSite);
- m_pDeskBar.Attach(pDeskBar);
+ m_pShellMenu = pShellMenu;
+ m_pBandSite = pBandSite;
+ m_pDeskBar = pDeskBar;
}
~CShellMenuCallback()
{
- m_pShellMenu.Release();
- m_pBandSite.Release();
- m_pDeskBar.Release();
}
HRESULT _SetProgramsFolder(IShellFolder * psf, LPITEMIDLIST pidl)
Modified: branches/shell-experiments/base/shell/rshell/precomp.h
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/precomp.h [iso-8859-1] (original)
+++ branches/shell-experiments/base/shell/rshell/precomp.h [iso-8859-1] Tue Oct 28
21:40:50 2014
@@ -38,9 +38,9 @@
#define COBJMACROS
//#define DEBUG_CCOMOBJECT
-//#define DEBUG_CCOMOBJECT_CREATION 1
-//#define DEBUG_CCOMOBJECT_DESTRUCTION 1
-//#define DEBUG_CCOMOBJECT_REFCOUNTING 0
+#define DEBUG_CCOMOBJECT_CREATION 1
+#define DEBUG_CCOMOBJECT_DESTRUCTION 1
+#define DEBUG_CCOMOBJECT_REFCOUNTING 1
#include <windef.h>
#include <winbase.h>
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] Tue Oct 28
21:40:50 2014
@@ -731,6 +731,24 @@
}
template<class T, class R>
+HRESULT inline ShellDebugObjectCreator(REFIID riid, R ** ppv)
+{
+ CComPtr<T> obj;
+ HRESULT hResult;
+
+ if (ppv == NULL)
+ return E_POINTER;
+ *ppv = NULL;
+ ATLTRY(obj = new CComDebugObject<T>);
+ if (obj.p == NULL)
+ return E_OUTOFMEMORY;
+ hResult = obj->QueryInterface(riid, reinterpret_cast<void **>(ppv));
+ if (FAILED(hResult))
+ return hResult;
+ return S_OK;
+}
+
+template<class T, class R>
HRESULT inline ShellObjectCreator(REFIID riid, R ** ppv)
{
CComPtr<T> obj;