diff --git a/accessible/ipc/DocAccessibleParent.cpp b/accessible/ipc/DocAccessibleParent.cpp index 7e281af5366..d3d882869d7 100644 --- a/accessible/ipc/DocAccessibleParent.cpp +++ b/accessible/ipc/DocAccessibleParent.cpp @@ -155,10 +155,12 @@ DocAccessibleParent::ShutdownAccessibles(ProxyEntry* entry, void*) } void -DocAccessibleParent::ActorDestroy(ActorDestroyReason aWhy) +DocAccessibleParent::Destroy() { MOZ_ASSERT(mChildDocs.IsEmpty(), "why wheren't the child docs destroyed already?"); + MOZ_ASSERT(!mShutdown); + mShutdown = true; mAccessibles.EnumerateEntries(ShutdownAccessibles, nullptr); ProxyDestroyed(this); diff --git a/accessible/ipc/DocAccessibleParent.h b/accessible/ipc/DocAccessibleParent.h index 9193bc45923..5b0ebd50d38 100644 --- a/accessible/ipc/DocAccessibleParent.h +++ b/accessible/ipc/DocAccessibleParent.h @@ -26,7 +26,7 @@ class DocAccessibleParent : public ProxyAccessible, { public: DocAccessibleParent() : - ProxyAccessible(this), mParentDoc(nullptr) + ProxyAccessible(this), mParentDoc(nullptr), mShutdown(false) { MOZ_COUNT_CTOR_INHERITED(DocAccessibleParent, ProxyAccessible); } ~DocAccessibleParent() { @@ -45,7 +45,12 @@ public: virtual bool RecvShowEvent(const ShowEventData& aData) MOZ_OVERRIDE; virtual bool RecvHideEvent(const uint64_t& aRootID) MOZ_OVERRIDE; - virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; + void Destroy(); + virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE + { + if (!mShutdown) + Destroy(); + } /* * Return the main processes representation of the parent document (if any) @@ -115,6 +120,7 @@ private: * proxy object so we can't use a real map. */ nsTHashtable mAccessibles; + bool mShutdown; }; } diff --git a/accessible/ipc/ProxyAccessible.cpp b/accessible/ipc/ProxyAccessible.cpp index 52dfb071ae4..06afa1085dd 100644 --- a/accessible/ipc/ProxyAccessible.cpp +++ b/accessible/ipc/ProxyAccessible.cpp @@ -23,6 +23,11 @@ ProxyAccessible::Shutdown() uint32_t childCount = mChildren.Length(); for (uint32_t idx = 0; idx < childCount; idx++) mChildren[idx]->Shutdown(); + } else { + if (mChildren.Length() != 1) + MOZ_CRASH("outer doc doesn't own adoc!"); + + static_cast(mChildren[0])->Destroy(); } mChildren.Clear();