Fixed leak of the BrowserWindow in WebCrawler / Added nsViewerApp::CloseWindow()

This commit is contained in:
pierre%netscape.com 1999-02-12 19:11:24 +00:00
parent d7c08c9ad1
commit b7382c0909
4 changed files with 14 additions and 3 deletions

View File

@ -315,9 +315,8 @@ HandleBrowserEvent(nsGUIEvent *aEvent)
case NS_DESTROY:
{
nsViewerApp* app = bw->mApp;
app->CloseWindow(bw);
result = nsEventStatus_eConsumeDoDefault;
bw->Close();
NS_RELEASE(bw);
#ifndef XP_MAC
// XXX Really shouldn't just exit, we should just notify somebody...

View File

@ -614,6 +614,16 @@ nsViewerApp::OpenWindow()
return NS_OK;
}
NS_IMETHODIMP
nsViewerApp::CloseWindow(nsBrowserWindow* aBrowserWindow)
{
aBrowserWindow->Close();
NS_RELEASE(aBrowserWindow);
mCrawler->SetBrowserWindow(nsnull);
return NS_OK;
}
NS_IMETHODIMP
nsViewerApp::ViewSource(nsString& aURL)
{

View File

@ -52,6 +52,7 @@ public:
NS_IMETHOD Initialize(int argc, char** argv);
NS_IMETHOD ProcessArguments(int argc, char** argv);
NS_IMETHOD OpenWindow();
NS_IMETHOD CloseWindow(nsBrowserWindow* aBrowserWindow);
NS_IMETHOD ViewSource(nsString& aURL);
NS_IMETHOD OpenWindow(PRUint32 aNewChromeMask, nsIBrowserWindow*& aNewWindow);
NS_IMETHOD CreateRobot(nsBrowserWindow* aWindow);

View File

@ -657,8 +657,9 @@ nsWebCrawler::FindMoreURLs()
void
nsWebCrawler::SetBrowserWindow(nsIBrowserWindow* aWindow)
{
NS_IF_RELEASE(mBrowser);
mBrowser = aWindow;
NS_ADDREF(mBrowser);
NS_IF_ADDREF(mBrowser);
}
static void