mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
When destroying an RDFElement, call SetParent(nsnull) on each of its children so that there aren't any dangling reference back to us (should a child leak, or be referred to by somebody else).
This commit is contained in:
parent
34576fe309
commit
533c62b3a8
@ -29,7 +29,6 @@
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsDOMEvent.h"
|
||||
@ -398,7 +397,21 @@ RDFElementImpl::~RDFElementImpl()
|
||||
//NS_IF_RELEASE(mParent) // not refcounted
|
||||
NS_IF_RELEASE(mTag);
|
||||
NS_IF_RELEASE(mListenerManager);
|
||||
NS_IF_RELEASE(mChildren);
|
||||
|
||||
if (mChildren) {
|
||||
// Force child's parent to be null. This ensures that we don't
|
||||
// have dangling pointers if a child gets leaked.
|
||||
PRUint32 cnt;
|
||||
mChildren->Count(&cnt);
|
||||
for (PRInt32 i = cnt - 1; i >= 0; --i) {
|
||||
nsISupports* isupports = mChildren->ElementAt(i);
|
||||
nsCOMPtr<nsIContent> child = do_QueryInterface(isupports);
|
||||
NS_RELEASE(isupports);
|
||||
|
||||
child->SetParent(nsnull);
|
||||
}
|
||||
NS_RELEASE(mChildren);
|
||||
}
|
||||
|
||||
// Release our broadcast listeners
|
||||
if (mBroadcastListeners != nsnull)
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsDOMEvent.h"
|
||||
@ -398,7 +397,21 @@ RDFElementImpl::~RDFElementImpl()
|
||||
//NS_IF_RELEASE(mParent) // not refcounted
|
||||
NS_IF_RELEASE(mTag);
|
||||
NS_IF_RELEASE(mListenerManager);
|
||||
NS_IF_RELEASE(mChildren);
|
||||
|
||||
if (mChildren) {
|
||||
// Force child's parent to be null. This ensures that we don't
|
||||
// have dangling pointers if a child gets leaked.
|
||||
PRUint32 cnt;
|
||||
mChildren->Count(&cnt);
|
||||
for (PRInt32 i = cnt - 1; i >= 0; --i) {
|
||||
nsISupports* isupports = mChildren->ElementAt(i);
|
||||
nsCOMPtr<nsIContent> child = do_QueryInterface(isupports);
|
||||
NS_RELEASE(isupports);
|
||||
|
||||
child->SetParent(nsnull);
|
||||
}
|
||||
NS_RELEASE(mChildren);
|
||||
}
|
||||
|
||||
// Release our broadcast listeners
|
||||
if (mBroadcastListeners != nsnull)
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsDOMEvent.h"
|
||||
@ -398,7 +397,21 @@ RDFElementImpl::~RDFElementImpl()
|
||||
//NS_IF_RELEASE(mParent) // not refcounted
|
||||
NS_IF_RELEASE(mTag);
|
||||
NS_IF_RELEASE(mListenerManager);
|
||||
NS_IF_RELEASE(mChildren);
|
||||
|
||||
if (mChildren) {
|
||||
// Force child's parent to be null. This ensures that we don't
|
||||
// have dangling pointers if a child gets leaked.
|
||||
PRUint32 cnt;
|
||||
mChildren->Count(&cnt);
|
||||
for (PRInt32 i = cnt - 1; i >= 0; --i) {
|
||||
nsISupports* isupports = mChildren->ElementAt(i);
|
||||
nsCOMPtr<nsIContent> child = do_QueryInterface(isupports);
|
||||
NS_RELEASE(isupports);
|
||||
|
||||
child->SetParent(nsnull);
|
||||
}
|
||||
NS_RELEASE(mChildren);
|
||||
}
|
||||
|
||||
// Release our broadcast listeners
|
||||
if (mBroadcastListeners != nsnull)
|
||||
|
Loading…
Reference in New Issue
Block a user