mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1288228 part 1: Move cleanup code from DOMSVGLength destructor into a helper-function. r=jwatt
MozReview-Commit-ID: 8CQCZZP8NUn --HG-- extra : rebase_source : 48e1311053c477c18af5b45172504ada4f752671
This commit is contained in:
parent
a2a8662207
commit
543ecd97c3
@ -140,21 +140,32 @@ DOMSVGLength::DOMSVGLength(nsSVGLength2* aVal, nsSVGElement* aSVGElement,
|
||||
{
|
||||
}
|
||||
|
||||
DOMSVGLength::~DOMSVGLength()
|
||||
void
|
||||
DOMSVGLength::CleanupWeakRefs()
|
||||
{
|
||||
// Our mList's weak ref to us must be nulled out when we die. If GC has
|
||||
// unlinked us using the cycle collector code, then that has already
|
||||
// happened, and mList is null.
|
||||
// Our mList's weak ref to us must be nulled out when we die (or when we're
|
||||
// cycle collected), so we that don't leave behind a pointer to
|
||||
// free / soon-to-be-free memory.
|
||||
if (mList) {
|
||||
MOZ_ASSERT(mList->mItems[mListIndex] == this,
|
||||
"Clearing out the wrong list index...?");
|
||||
mList->mItems[mListIndex] = nullptr;
|
||||
}
|
||||
|
||||
// Similarly, we must update the tearoff table to remove its (non-owning)
|
||||
// pointer to mVal.
|
||||
if (mVal) {
|
||||
auto& table = mIsAnimValItem ? sAnimSVGLengthTearOffTable : sBaseSVGLengthTearOffTable;
|
||||
auto& table = mIsAnimValItem ?
|
||||
sAnimSVGLengthTearOffTable : sBaseSVGLengthTearOffTable;
|
||||
table.RemoveTearoff(mVal);
|
||||
}
|
||||
}
|
||||
|
||||
DOMSVGLength::~DOMSVGLength()
|
||||
{
|
||||
CleanupWeakRefs();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMSVGLength>
|
||||
DOMSVGLength::GetTearOff(nsSVGLength2* aVal, nsSVGElement* aSVGElement,
|
||||
bool aAnimVal)
|
||||
|
@ -223,6 +223,13 @@ private:
|
||||
bool IndexIsValid();
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Clears soon-to-be-invalid weak references in external objects that were
|
||||
* set up during the creation of this object. This should be called during
|
||||
* destruction and during cycle collection.
|
||||
*/
|
||||
void CleanupWeakRefs();
|
||||
|
||||
RefPtr<DOMSVGLengthList> mList;
|
||||
|
||||
// Bounds for the following are checked in the ctor, so be sure to update
|
||||
|
Loading…
Reference in New Issue
Block a user