mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Fixing bug 118194. Make sure we don't leave dangling document pointers in the content tree when the document goes away. r=bzbarsky@mit.edu, sr=vidur@netscape.com
This commit is contained in:
parent
882cccf833
commit
806d729272
@ -508,6 +508,28 @@ nsDocument::~nsDocument()
|
||||
NS_RELEASE(subdoc);
|
||||
}
|
||||
|
||||
if (mRootContent) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
|
||||
mRootContent->GetDocument(*getter_AddRefs(doc));
|
||||
|
||||
if (doc) {
|
||||
// The root content still has a pointer back to the document,
|
||||
// clear the document pointer in all children.
|
||||
|
||||
PRUint32 count;
|
||||
mChildren->Count(&count);
|
||||
for (indx = 0; (PRUint32)indx < count; indx++) {
|
||||
nsCOMPtr<nsIContent> content;
|
||||
|
||||
mChildren->QueryElementAt(indx, NS_GET_IID(nsIContent),
|
||||
getter_AddRefs(content));
|
||||
|
||||
content->SetDocument(nsnull, PR_TRUE, PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mRootContent = nsnull;
|
||||
mChildren->Clear();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user