diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index e6fd568bf4b0..2386d3c06283 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -1328,12 +1328,17 @@ nsWindow::Destroy(void) mGeckoViewSupport = nullptr; } + // Stuff below may release the last ref to this + nsCOMPtr kungFuDeathGrip(this); + while (mChildren.Length()) { // why do we still have children? ALOG("### Warning: Destroying window %p and reparenting child %p to null!", (void*)this, (void*)mChildren[0]); mChildren[0]->SetParent(nullptr); } + nsBaseWidget::Destroy(); + if (IsTopLevel()) gTopLevelWindows.RemoveElement(this);