зеркало из https://github.com/mozilla/gecko-dev.git
Safely iterate parents' children in widget destructors on OS X. b=503196 r=josh
This commit is contained in:
Родитель
efbee7cd1c
Коммит
040ee0abe0
|
@ -528,9 +528,12 @@ nsChildView::nsChildView() : nsBaseWidget()
|
|||
|
||||
nsChildView::~nsChildView()
|
||||
{
|
||||
// notify the children that we're gone
|
||||
for (nsIWidget* kid = mFirstChild; kid; kid = kid->GetNextSibling()) {
|
||||
// Notify the children that we're gone. childView->ResetParent() can change
|
||||
// our list of children while it's being iterated, so the way we iterate the
|
||||
// list must allow for this.
|
||||
for (nsIWidget* kid = mLastChild; kid;) {
|
||||
nsChildView* childView = static_cast<nsChildView*>(kid);
|
||||
kid = kid->GetPrevSibling();
|
||||
childView->ResetParent();
|
||||
}
|
||||
|
||||
|
|
|
@ -161,16 +161,20 @@ nsCocoaWindow::~nsCocoaWindow()
|
|||
|
||||
// Notify the children that we're gone. Popup windows (e.g. tooltips) can
|
||||
// have nsChildView children. 'kid' is an nsChildView object if and only if
|
||||
// its 'type' is 'eWindowType_child'.
|
||||
for (nsIWidget* kid = mFirstChild; kid; kid = kid->GetNextSibling()) {
|
||||
// its 'type' is 'eWindowType_child'. childView->ResetParent() can change
|
||||
// our list of children while it's being iterated, so the way we iterate the
|
||||
// list must allow for this.
|
||||
for (nsIWidget* kid = mLastChild; kid;) {
|
||||
nsWindowType kidType;
|
||||
kid->GetWindowType(kidType);
|
||||
if (kidType == eWindowType_child) {
|
||||
nsChildView* childView = static_cast<nsChildView*>(kid);
|
||||
kid = kid->GetPrevSibling();
|
||||
childView->ResetParent();
|
||||
} else {
|
||||
nsCocoaWindow* childWindow = static_cast<nsCocoaWindow*>(kid);
|
||||
childWindow->mParent = nsnull;
|
||||
kid = kid->GetPrevSibling();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче