Fixing bug 143782. Don't double release the content pointers in mCurrentEventContentStack when a presshell is destroyed from within an event handler called through the presshell. r=dbaron@fas.harvard.edu, sr=protts@netscape.com

git-svn-id: svn://10.0.0.236/trunk@123710 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jst%netscape.com 2002-06-20 20:14:59 +00:00
parent 800eb0e544
commit e7622066bd
2 changed files with 36 additions and 12 deletions

View File

@ -1667,6 +1667,11 @@ PresShell::~PresShell()
Destroy();
}
NS_ASSERTION(mCurrentEventContentStack.Count() == 0,
"Huh, event content left on the stack in pres shell dtor!");
NS_IF_RELEASE(mCurrentEventContent);
// if we allocated any stack memory free it.
FreeDynamicStack();
}
@ -1845,14 +1850,21 @@ PresShell::Destroy()
// Clobber weak leaks in case of re-entrancy during tear down
mHistoryState = nsnull;
// release current event content and any content on event stack
NS_IF_RELEASE(mCurrentEventContent);
// We can't release all the event content in
// mCurrentEventContentStack here since there might be code on the
// stack that will release the event content too. Double release
// bad!
PRInt32 i, count = mCurrentEventContentStack.Count();
nsIContent* currentEventContent;
// The frames will be torn down, so remove them from the current
// event frame stack (since they'd be dangling references if we'd
// leave them in) and null out the mCurrentEventFrame pointer as
// well.
mCurrentEventFrame = nsnull;
PRInt32 i, count = mCurrentEventFrameStack.Count();
for (i = 0; i < count; i++) {
currentEventContent = (nsIContent*)mCurrentEventContentStack.ElementAt(i);
NS_IF_RELEASE(currentEventContent);
mCurrentEventFrameStack.ReplaceElementAt(nsnull, i);
}
if (mViewManager) {

View File

@ -1667,6 +1667,11 @@ PresShell::~PresShell()
Destroy();
}
NS_ASSERTION(mCurrentEventContentStack.Count() == 0,
"Huh, event content left on the stack in pres shell dtor!");
NS_IF_RELEASE(mCurrentEventContent);
// if we allocated any stack memory free it.
FreeDynamicStack();
}
@ -1845,14 +1850,21 @@ PresShell::Destroy()
// Clobber weak leaks in case of re-entrancy during tear down
mHistoryState = nsnull;
// release current event content and any content on event stack
NS_IF_RELEASE(mCurrentEventContent);
// We can't release all the event content in
// mCurrentEventContentStack here since there might be code on the
// stack that will release the event content too. Double release
// bad!
PRInt32 i, count = mCurrentEventContentStack.Count();
nsIContent* currentEventContent;
// The frames will be torn down, so remove them from the current
// event frame stack (since they'd be dangling references if we'd
// leave them in) and null out the mCurrentEventFrame pointer as
// well.
mCurrentEventFrame = nsnull;
PRInt32 i, count = mCurrentEventFrameStack.Count();
for (i = 0; i < count; i++) {
currentEventContent = (nsIContent*)mCurrentEventContentStack.ElementAt(i);
NS_IF_RELEASE(currentEventContent);
mCurrentEventFrameStack.ReplaceElementAt(nsnull, i);
}
if (mViewManager) {