Bug 753665 - Fix possible corruption in the window parent chain. r=blassey
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -236,20 +236,20 @@ nsWindow::Create(nsIWidget *aParent,
return NS_OK;
}
NS_IMETHODIMP
nsWindow::Destroy(void)
{
nsBaseWidget::mOnDestroyCalled = true;
- for (PRUint32 i = 0; i < mChildren.Length(); ++i) {
+ while (mChildren.Length()) {
// why do we still have children?
- ALOG("### Warning: Destroying window %p and reparenting child %p to null!", (void*)this, (void*)mChildren[i]);
- mChildren[i]->SetParent(nsnull);
+ ALOG("### Warning: Destroying window %p and reparenting child %p to null!", (void*)this, (void*)mChildren[0]);
+ mChildren[0]->SetParent(nsnull);
}
if (IsTopLevel())
gTopLevelWindows.RemoveElement(this);
if (mParent)
mParent->mChildren.RemoveElement(this);