Fixed crash on Quit due to a double delete of the nsAppShellService (it was noticed with debug builds on the Mac but it was affecting other platforms too)

This commit is contained in:
pierre@netscape.com
1999-09-11 06:25:51 +00:00
parent 67a0dc4efe
commit 8050c4fdeb
2 changed files with 13 additions and 1 deletions

View File

@@ -121,6 +121,7 @@ protected:
nsICmdLineService* mCmdLineService;
nsIWindowMediator* mWindowMediator;
nsCOMPtr<nsIWebShellWindow> mHiddenWindow;
PRBool mDeleteCalled;
};
nsAppShellService::nsAppShellService() : mWindowMediator( NULL )
@@ -130,10 +131,12 @@ nsAppShellService::nsAppShellService() : mWindowMediator( NULL )
mAppShell = nsnull;
mWindowList = nsnull;
mCmdLineService = nsnull;
mDeleteCalled = PR_FALSE;
}
nsAppShellService::~nsAppShellService()
{
mDeleteCalled = PR_TRUE;
NS_IF_RELEASE(mAppShell);
NS_IF_RELEASE(mWindowList);
NS_IF_RELEASE(mCmdLineService);
@@ -721,6 +724,14 @@ nsAppShellService::UnregisterTopLevelWindow(nsIWebShellWindow* aWindow)
service->UnregisterWindow( aWindow );
nsServiceManager::ReleaseService(kWindowMediatorCID, service);
}
if (mDeleteCalled) {
// return an error code in order to:
// - avoid doing anything with other member variables while we are in the destructor
// - notify the caller not to release the AppShellService after unregistering the window
// (we don't want to be deleted twice consecutively to mHiddenWindow->Close() in our destructor)
return NS_ERROR_FAILURE;
}
nsresult rv;