diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 21:06:04 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 21:06:04 +0000 |
commit | 8c57de2ed242d996440048e2bfd4d8ac1ea55745 (patch) | |
tree | 2e9224d7675be2c094a698b2917deaca03c60174 /views | |
parent | 3a9c26f147ab16179197bd4460f4ec6c476afcf7 (diff) | |
download | chromium_src-8c57de2ed242d996440048e2bfd4d8ac1ea55745.zip chromium_src-8c57de2ed242d996440048e2bfd4d8ac1ea55745.tar.gz chromium_src-8c57de2ed242d996440048e2bfd4d8ac1ea55745.tar.bz2 |
remove itself from parent when deleted.
In most case, this won't happen because
the parent view sets child view's parent to
NULL before deletion. This is necessary to safely
delete view that is not owned by parent.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/872006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41485 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/view.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/views/view.cc b/views/view.cc index 437b3b7..abc2957 100644 --- a/views/view.cc +++ b/views/view.cc @@ -76,12 +76,14 @@ View::View() } View::~View() { + if (parent_) + parent_->RemoveChildView(this); + int c = static_cast<int>(child_views_.size()); while (--c >= 0) { + child_views_[c]->SetParent(NULL); if (child_views_[c]->IsParentOwned()) delete child_views_[c]; - else - child_views_[c]->SetParent(NULL); } #if defined(OS_WIN) |