mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[BROWSEUI/RSHELL]
* Begin fixing the process of destroying the related objects when closing the window, so that eventually the filebrowser/explorer process will properly exit cleanly when no more windows are open. svn path=/branches/shell-experiments/; revision=63535
This commit is contained in:
parent
13c7cade20
commit
3a54fd538b
4 changed files with 146 additions and 25 deletions
|
@ -74,7 +74,8 @@ CMenuBand::CMenuBand() :
|
|||
m_hotBar(NULL),
|
||||
m_hotItem(-1),
|
||||
m_popupBar(NULL),
|
||||
m_popupItem(-1)
|
||||
m_popupItem(-1),
|
||||
m_Show(FALSE)
|
||||
{
|
||||
m_focusManager = CMenuFocusManager::AcquireManager();
|
||||
}
|
||||
|
@ -363,6 +364,9 @@ HRESULT STDMETHODCALLTYPE CMenuBand::ShowDW(BOOL fShow)
|
|||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (m_Show == fShow)
|
||||
return S_OK;
|
||||
|
||||
if (m_staticToolbar != NULL)
|
||||
{
|
||||
hr = m_staticToolbar->ShowWindow(fShow);
|
||||
|
@ -403,6 +407,8 @@ HRESULT STDMETHODCALLTYPE CMenuBand::ShowDW(BOOL fShow)
|
|||
hr = m_focusManager->PopMenuBar(this);
|
||||
}
|
||||
|
||||
m_Show = fShow;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,8 @@ private:
|
|||
CMenuToolbarBase * m_popupBar;
|
||||
INT m_popupItem;
|
||||
|
||||
BOOL m_Show;
|
||||
|
||||
public:
|
||||
CMenuBand();
|
||||
~CMenuBand();
|
||||
|
|
|
@ -819,19 +819,87 @@ HRESULT STDMETHODCALLTYPE CInternetToolbar::ContextSensitiveHelp(BOOL fEnterMode
|
|||
|
||||
HRESULT STDMETHODCALLTYPE CInternetToolbar::ShowDW(BOOL fShow)
|
||||
{
|
||||
CComPtr<IDockingWindow> dockingWindow;
|
||||
HRESULT hResult;
|
||||
|
||||
// show the bar here
|
||||
if (fShow)
|
||||
{
|
||||
hResult = ReserveBorderSpace();
|
||||
}
|
||||
if (fMenuBar)
|
||||
{
|
||||
CComPtr<IDockingWindow> dockingWindow;
|
||||
hResult = fMenuBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
|
||||
hResult = dockingWindow->ShowDW(fShow);
|
||||
}
|
||||
if (fControlsBar)
|
||||
{
|
||||
CComPtr<IDockingWindow> dockingWindow;
|
||||
hResult = fControlsBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
|
||||
hResult = dockingWindow->ShowDW(fShow);
|
||||
}
|
||||
if (fNavigationBar)
|
||||
{
|
||||
CComPtr<IDockingWindow> dockingWindow;
|
||||
hResult = fNavigationBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
|
||||
hResult = dockingWindow->ShowDW(fShow);
|
||||
}
|
||||
if (fLogoBar)
|
||||
{
|
||||
CComPtr<IDockingWindow> dockingWindow;
|
||||
hResult = fLogoBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
|
||||
hResult = dockingWindow->ShowDW(fShow);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void ReleaseCComPtrExpectZero(CComPtr<T>& cptr)
|
||||
{
|
||||
if (cptr.p != NULL)
|
||||
{
|
||||
int nrc = cptr->Release();
|
||||
if (nrc > 0)
|
||||
{
|
||||
DbgPrint("WARNING: Unexpected RefCount > 0!\n");
|
||||
}
|
||||
cptr.Detach();
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CInternetToolbar::CloseDW(DWORD dwReserved)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
HRESULT hResult;
|
||||
|
||||
if (fMenuBar)
|
||||
{
|
||||
CComPtr<IDockingWindow> dockingWindow;
|
||||
hResult = fMenuBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
|
||||
hResult = dockingWindow->CloseDW(dwReserved);
|
||||
}
|
||||
ReleaseCComPtrExpectZero(fMenuBar);
|
||||
if (fControlsBar)
|
||||
{
|
||||
CComPtr<IDockingWindow> dockingWindow;
|
||||
hResult = fControlsBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
|
||||
hResult = dockingWindow->CloseDW(dwReserved);
|
||||
}
|
||||
ReleaseCComPtrExpectZero(fControlsBar);
|
||||
if (fNavigationBar)
|
||||
{
|
||||
CComPtr<IDockingWindow> dockingWindow;
|
||||
hResult = fNavigationBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
|
||||
hResult = dockingWindow->CloseDW(dwReserved);
|
||||
}
|
||||
ReleaseCComPtrExpectZero(fNavigationBar);
|
||||
if (fLogoBar)
|
||||
{
|
||||
CComPtr<IDockingWindow> dockingWindow;
|
||||
hResult = fLogoBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
|
||||
hResult = dockingWindow->CloseDW(dwReserved);
|
||||
}
|
||||
ReleaseCComPtrExpectZero(fLogoBar);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CInternetToolbar::ResizeBorderDW(LPCRECT prcBorder,
|
||||
|
|
|
@ -3062,9 +3062,49 @@ LRESULT CShellBrowser::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &b
|
|||
return 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void ReleaseCComPtrExpectZero(CComPtr<T>& cptr)
|
||||
{
|
||||
if (cptr.p != NULL)
|
||||
{
|
||||
int nrc = cptr->Release();
|
||||
if (nrc > 0)
|
||||
{
|
||||
DbgPrint("WARNING: Unexpected RefCount > 0!\n");
|
||||
}
|
||||
cptr.Detach();
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CShellBrowser::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
|
||||
{
|
||||
HRESULT hr;
|
||||
// TODO: rip down everything
|
||||
{
|
||||
fCurrentShellView->DestroyViewWindow();
|
||||
fCurrentShellView->UIActivate(SVUIA_DEACTIVATE);
|
||||
ReleaseCComPtrExpectZero(fCurrentShellView);
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (fClientBars[i].clientBar == NULL)
|
||||
continue;
|
||||
IDockingWindow * pdw;
|
||||
hr = fClientBars[i].clientBar->QueryInterface(IID_PPV_ARG(IDockingWindow, &pdw));
|
||||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
continue;
|
||||
pdw->ShowDW(FALSE);
|
||||
pdw->CloseDW(0);
|
||||
pdw->Release();
|
||||
ReleaseCComPtrExpectZero(fClientBars[i].clientBar);
|
||||
}
|
||||
ReleaseCComPtrExpectZero(fTravelLog);
|
||||
|
||||
fCurrentShellFolder.Release();
|
||||
ILFree(fCurrentDirectoryPIDL);
|
||||
::DestroyWindow(fStatusBar);
|
||||
DestroyMenu(fCurrentMenuBar);
|
||||
}
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
|
@ -3312,31 +3352,20 @@ LRESULT CShellBrowser::RelayCommands(UINT uMsg, WPARAM wParam, LPARAM lParam, BO
|
|||
|
||||
static HRESULT ExplorerMessageLoop(IEThreadParamBlock * parameters)
|
||||
{
|
||||
CComPtr<IShellBrowser> shellBrowser;
|
||||
CComObject<CShellBrowser> *theCabinet;
|
||||
CComPtr<CComObject<CShellBrowser>> theCabinet;
|
||||
HRESULT hResult;
|
||||
MSG Msg;
|
||||
BOOL Ret;
|
||||
|
||||
OleInitialize(NULL);
|
||||
|
||||
ATLTRY(theCabinet = new CComObject<CShellBrowser>);
|
||||
if (theCabinet == NULL)
|
||||
{
|
||||
hResult = E_OUTOFMEMORY;
|
||||
goto uninitialize;
|
||||
}
|
||||
|
||||
hResult = theCabinet->QueryInterface(IID_PPV_ARG(IShellBrowser, &shellBrowser));
|
||||
if (FAILED(hResult))
|
||||
{
|
||||
delete theCabinet;
|
||||
goto uninitialize;
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
hResult = theCabinet->Initialize(parameters->directoryPIDL, 0, 0, 0);
|
||||
if (FAILED(hResult))
|
||||
goto uninitialize;
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
while ((Ret = GetMessage(&Msg, NULL, 0, 0)) != 0)
|
||||
{
|
||||
|
@ -3356,13 +3385,29 @@ static HRESULT ExplorerMessageLoop(IEThreadParamBlock * parameters)
|
|||
break;
|
||||
}
|
||||
|
||||
uninitialize:
|
||||
OleUninitialize();
|
||||
//TerminateProcess(GetCurrentProcess(), hResult);
|
||||
|
||||
int nrc = theCabinet->Release();
|
||||
if (nrc > 0)
|
||||
{
|
||||
DbgPrint("WARNING: There are %d references to the CShellBrowser active or leaked, process will never terminate.\n");
|
||||
}
|
||||
|
||||
theCabinet.Detach();
|
||||
|
||||
return hResult;
|
||||
}
|
||||
|
||||
DWORD WINAPI BrowserThreadProc(LPVOID lpThreadParameter)
|
||||
{
|
||||
HRESULT hr;
|
||||
IEThreadParamBlock * parameters = (IEThreadParamBlock *) lpThreadParameter;
|
||||
return ExplorerMessageLoop(parameters);
|
||||
|
||||
OleInitialize(NULL);
|
||||
|
||||
ATLTRY(hr = ExplorerMessageLoop(parameters));
|
||||
|
||||
OleUninitialize();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue