Bug 223736 nsWebShellWindow::Destroy should call nsWebShellWindow::Destroy before destroying its timer and calling release_this

r=danm sr=dbaron a=dbaron
This commit is contained in:
timeless%mozdev.org 2003-11-23 14:01:43 +00:00
parent 6d3c3df523
commit 149e7858a1

View File

@ -210,11 +210,13 @@ nsWebShellWindow::~nsWebShellWindow()
mWindow->SetClientData(0); mWindow->SetClientData(0);
mWindow = nsnull; // Force release here. mWindow = nsnull; // Force release here.
PR_Lock(mSPTimerLock); if (mSPTimerLock) {
if (mSPTimer) PR_Lock(mSPTimerLock);
mSPTimer->Cancel(); if (mSPTimer)
PR_Unlock(mSPTimerLock); mSPTimer->Cancel();
PR_DestroyLock(mSPTimerLock); PR_Unlock(mSPTimerLock);
PR_DestroyLock(mSPTimerLock);
}
} }
NS_IMPL_THREADSAFE_ADDREF(nsWebShellWindow) NS_IMPL_THREADSAFE_ADDREF(nsWebShellWindow)
@ -1174,6 +1176,9 @@ nsWebShellWindow::DestroyModalDialogEvent(PLEvent *aEvent)
void void
nsWebShellWindow::SetPersistenceTimer(PRUint32 aDirtyFlags) nsWebShellWindow::SetPersistenceTimer(PRUint32 aDirtyFlags)
{ {
if (!mSPTimerLock)
return;
PR_Lock(mSPTimerLock); PR_Lock(mSPTimerLock);
if (mSPTimer) { if (mSPTimer) {
mSPTimer->SetDelay(SIZE_PERSISTENCE_TIMEOUT); mSPTimer->SetDelay(SIZE_PERSISTENCE_TIMEOUT);
@ -1195,6 +1200,8 @@ void
nsWebShellWindow::FirePersistenceTimer(nsITimer *aTimer, void *aClosure) nsWebShellWindow::FirePersistenceTimer(nsITimer *aTimer, void *aClosure)
{ {
nsWebShellWindow *win = NS_STATIC_CAST(nsWebShellWindow *, aClosure); nsWebShellWindow *win = NS_STATIC_CAST(nsWebShellWindow *, aClosure);
if (!win->mSPTimerLock)
return;
PR_Lock(win->mSPTimerLock); PR_Lock(win->mSPTimerLock);
win->SavePersistentAttributes(); win->SavePersistentAttributes();
PR_Unlock(win->mSPTimerLock); PR_Unlock(win->mSPTimerLock);
@ -1654,14 +1661,17 @@ NS_IMETHODIMP nsWebShellWindow::Destroy()
} }
#endif #endif
nsCOMPtr<nsIWebShellWindow> kungFuDeathGrip(this);
PR_Lock(mSPTimerLock); PR_Lock(mSPTimerLock);
if (mSPTimer) { if (mSPTimer) {
mSPTimer->Cancel(); mSPTimer->Cancel();
mSPTimer = nsnull;
SavePersistentAttributes(); SavePersistentAttributes();
mSPTimer = nsnull;
NS_RELEASE_THIS(); // the timer held a reference to us NS_RELEASE_THIS(); // the timer held a reference to us
} }
PR_Unlock(mSPTimerLock); PR_Unlock(mSPTimerLock);
PR_DestroyLock(mSPTimerLock);
mSPTimerLock = nsnull;
return nsXULWindow::Destroy(); return nsXULWindow::Destroy();
} }