diff --git a/mozilla/xpcom/ds/nsAtomTable.cpp b/mozilla/xpcom/ds/nsAtomTable.cpp index b2aa909b54f..9ad1536bde0 100644 --- a/mozilla/xpcom/ds/nsAtomTable.cpp +++ b/mozilla/xpcom/ds/nsAtomTable.cpp @@ -397,7 +397,7 @@ AtomImpl::~AtomImpl() // Permanent atoms are removed from the hashtable at shutdown, and we // don't want to remove them twice. See comment above in // |AtomTableClearEntry|. - if (!IsPermanent()) { + if (!IsPermanentInDestructor()) { AtomTableEntry key(mString); PL_DHashTableOperate(&gAtomTable, &key, PL_DHASH_REMOVE); if (gAtomTable.entryCount == 0) { @@ -413,6 +413,11 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(AtomImpl, nsIAtom) PermanentAtomImpl::PermanentAtomImpl() : AtomImpl() { +} + +PermanentAtomImpl::~PermanentAtomImpl() +{ + // So we can tell if we were permanent while running the base class dtor. mRefCnt = REFCNT_PERMANENT_SENTINEL; } @@ -426,6 +431,18 @@ NS_IMETHODIMP_(nsrefcnt) PermanentAtomImpl::Release() return 1; } +/* virtual */ PRBool +AtomImpl::IsPermanent() +{ + return PR_FALSE; +} + +/* virtual */ PRBool +PermanentAtomImpl::IsPermanent() +{ + return PR_TRUE; +} + void* AtomImpl::operator new ( size_t size, const nsACString& aString ) CPP_THROW_NEW { /* diff --git a/mozilla/xpcom/ds/nsAtomTable.h b/mozilla/xpcom/ds/nsAtomTable.h index 65f170d64cf..53fc5ef3bab 100644 --- a/mozilla/xpcom/ds/nsAtomTable.h +++ b/mozilla/xpcom/ds/nsAtomTable.h @@ -61,7 +61,12 @@ public: enum { REFCNT_PERMANENT_SENTINEL = PR_UINT32_MAX }; - PRBool IsPermanent() { return mRefCnt == REFCNT_PERMANENT_SENTINEL; } + virtual PRBool IsPermanent(); + + // We can't use the virtual function in the base class destructor. + PRBool IsPermanentInDestructor() { + return mRefCnt == REFCNT_PERMANENT_SENTINEL; + } void* operator new(size_t size, const nsACString& aString) CPP_THROW_NEW; @@ -84,9 +89,12 @@ public: class PermanentAtomImpl : public AtomImpl { public: PermanentAtomImpl(); + ~PermanentAtomImpl(); NS_IMETHOD_(nsrefcnt) AddRef(); NS_IMETHOD_(nsrefcnt) Release(); + virtual PRBool IsPermanent(); + void* operator new(size_t size, const nsACString& aString) CPP_THROW_NEW { return AtomImpl::operator new(size, aString); }