Author: gadamopoulos
Date: Tue Nov 8 23:38:42 2016
New Revision: 73175
URL:
http://svn.reactos.org/svn/reactos?rev=73175&view=rev
Log:
[BROWSEUI]
- CAddressBand: Call the SetOwner method with NULL parameter to CAddressEditBox to let it
know that it should deinitialize.
- CAddressEditBox: Release the connection with the browse window and release the pointer
to the site during deinitialization.
- CInternetToolbar: Destroy the toolbar and release pointers when CloseDW method gets
called.
- CBaseBar: Destroy the window when SetClient is called with NULL parameter.
- CToolbarProxy: Add a Destroy method to release resources because we hold a pointer to
the CInternetToolbar.
- CShellBrowser: When storing the pointer to the new basebar add a new reference because
we directly change the pointer in the smart pointer and not the smart pointer itself.
Destroy the toolbar proxy and properly release all references to containted objects. Also
expect the reference count of the shell view to reach zero after the internet toolbar gets
freed because it also keeps a reference.
This should fix all the leaking objects and windows when closing the shell browser. It
should also fix CORE-12066.
Modified:
trunk/reactos/dll/win32/browseui/addressband.cpp
trunk/reactos/dll/win32/browseui/addresseditbox.cpp
trunk/reactos/dll/win32/browseui/basebar.cpp
trunk/reactos/dll/win32/browseui/internettoolbar.cpp
trunk/reactos/dll/win32/browseui/shellbrowser.cpp
Modified: trunk/reactos/dll/win32/browseui/addressband.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/browseui/address…
==============================================================================
--- trunk/reactos/dll/win32/browseui/addressband.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/browseui/addressband.cpp [iso-8859-1] Tue Nov 8 23:38:42
2016
@@ -197,7 +197,10 @@
m_hWnd = NULL;
- IUnknown_SetSite(fAddressEditBox, NULL);
+ CComPtr<IShellService> pservice;
+ HRESULT hres = fAddressEditBox->QueryInterface(IID_PPV_ARG(IShellService,
&pservice));
+ if (SUCCEEDED(hres ))
+ pservice->SetOwner(NULL);
if (fAddressEditBox) fAddressEditBox.Release();
if (fSite) fSite.Release();
Modified: trunk/reactos/dll/win32/browseui/addresseditbox.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/browseui/address…
==============================================================================
--- trunk/reactos/dll/win32/browseui/addresseditbox.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/browseui/addresseditbox.cpp [iso-8859-1] Tue Nov 8 23:38:42
2016
@@ -43,8 +43,16 @@
{
}
-HRESULT STDMETHODCALLTYPE CAddressEditBox::SetOwner(IUnknown *)
-{
+HRESULT STDMETHODCALLTYPE CAddressEditBox::SetOwner(IUnknown *pOwner)
+{
+ if (!pOwner)
+ {
+ CComPtr<IBrowserService> browserService;
+ HRESULT hResult = IUnknown_QueryService(fSite, SID_SShellBrowser,
IID_PPV_ARG(IBrowserService, &browserService));
+ if (SUCCEEDED(hResult))
+ AtlUnadvise(browserService, DIID_DWebBrowserEvents, fAdviseCookie);
+ fSite = NULL;
+ }
// connect to browser connection point
return 0;
}
Modified: trunk/reactos/dll/win32/browseui/basebar.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/browseui/basebar…
==============================================================================
--- trunk/reactos/dll/win32/browseui/basebar.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/browseui/basebar.cpp [iso-8859-1] Tue Nov 8 23:38:42 2016
@@ -328,6 +328,10 @@
WS_VISIBLE | WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
WS_EX_TOOLWINDOW);
ReserveBorderSpace();
}
+ else
+ {
+ DestroyWindow();
+ }
return S_OK;
}
Modified: trunk/reactos/dll/win32/browseui/internettoolbar.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/browseui/interne…
==============================================================================
--- trunk/reactos/dll/win32/browseui/internettoolbar.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/browseui/internettoolbar.cpp [iso-8859-1] Tue Nov 8 23:38:42
2016
@@ -934,6 +934,8 @@
return hResult;
ReleaseCComPtrExpectZero(fLogoBar);
}
+
+ SetSite(NULL);
return S_OK;
}
Modified: trunk/reactos/dll/win32/browseui/shellbrowser.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/browseui/shellbr…
==============================================================================
--- trunk/reactos/dll/win32/browseui/shellbrowser.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/browseui/shellbrowser.cpp [iso-8859-1] Tue Nov 8 23:38:42
2016
@@ -179,7 +179,7 @@
CComPtr<IExplorerToolbar> fExplorerToolbar;
public:
void Initialize(HWND parent, IUnknown *explorerToolbar);
-
+ void Destroy();
private:
// message handlers
@@ -205,6 +205,12 @@
hResult = explorerToolbar->QueryInterface(
IID_PPV_ARG(IExplorerToolbar, &fExplorerToolbar));
}
+}
+
+void CToolbarProxy::Destroy()
+{
+ DestroyWindow();
+ fExplorerToolbar = NULL;
}
LRESULT CToolbarProxy::OnAddBitmap(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
&bHandled)
@@ -1116,6 +1122,7 @@
// we have to store our basebar into cache now
*cache = newBaseBar;
+ newBaseBar->AddRef();
// tell the new base bar about the shell browser
hResult = IUnknown_SetSite(newBaseBar, static_cast<IDropTarget *>(this));
@@ -3362,9 +3369,10 @@
// TODO: rip down everything
{
+ fToolbarProxy.Destroy();
+
fCurrentShellView->DestroyViewWindow();
fCurrentShellView->UIActivate(SVUIA_DEACTIVATE);
- ReleaseCComPtrExpectZero(fCurrentShellView);
for (int i = 0; i < 3; i++)
{
@@ -3393,16 +3401,14 @@
}
}
pdw->CloseDW(0);
+
+ pClient = NULL;
+ pBarSite = NULL;
pdw = NULL;
- /* For some reasons, it's like we miss some AddRef in ATL when
QueryInterface on
- * same interface or inherited one, so we are removing already removed (!)
object.
- * TODO: check with MSVC's ATL to see if this behaviour happens too
- */
- bar.Detach();
- pClient.Detach();
- pBarSite.Detach();
+ bar = NULL;
ReleaseCComPtrExpectZero(fClientBars[i].clientBar);
}
+ ReleaseCComPtrExpectZero(fCurrentShellView);
ReleaseCComPtrExpectZero(fTravelLog);
fCurrentShellFolder.Release();