Bug 1203423 - Move call to AddClone outside nsMutationReceiver constructor; r=smaug

This is to avoid performing an AddRef on a potentially derived object
where the subclass constructors have yet to run.
This commit is contained in:
Brian Birtles 2015-09-11 15:02:04 +09:00
parent 24dd86d754
commit 9d3f4a6884

View File

@ -324,6 +324,7 @@ public:
nsMutationReceiverBase* aParent)
{
nsMutationReceiver* r = new nsMutationReceiver(aRegisterTarget, aParent);
aParent->AddClone(r);
r->AddObserver();
return r;
}
@ -385,7 +386,6 @@ protected:
{
NS_ASSERTION(!static_cast<nsMutationReceiver*>(aParent)->GetParent(),
"Shouldn't create deep observer hierarchies!");
aParent->AddClone(this);
}
virtual void AddMutationObserver() override
@ -409,6 +409,7 @@ public:
nsMutationReceiverBase* aParent)
{
nsAnimationReceiver* r = new nsAnimationReceiver(aRegisterTarget, aParent);
aParent->AddClone(r);
r->AddObserver();
return r;
}