summaryrefslogtreecommitdiffstats
path: root/ui/aura/window.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-06 02:59:09 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-06 02:59:09 +0000
commit3077cb5f7e14cf8f82ea1c39029f3b02ec9ac7ac (patch)
tree8772c4b453a6a3b7ffae533af002e3baa55c1fbc /ui/aura/window.cc
parent46934c09bb8436145897cec8a8693e09b51110e3 (diff)
downloadchromium_src-3077cb5f7e14cf8f82ea1c39029f3b02ec9ac7ac.zip
chromium_src-3077cb5f7e14cf8f82ea1c39029f3b02ec9ac7ac.tar.gz
chromium_src-3077cb5f7e14cf8f82ea1c39029f3b02ec9ac7ac.tar.bz2
Support non-hierarchy ownership for aura::Windows.
BUG=none TEST=none Review URL: http://codereview.chromium.org/10007015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura/window.cc')
-rw-r--r--ui/aura/window.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index b91eccc..c48a622 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -47,6 +47,7 @@ bool Window::TestApi::OwnsLayer() const {
Window::Window(WindowDelegate* delegate)
: type_(client::WINDOW_TYPE_UNKNOWN),
+ owned_by_parent_(true),
delegate_(delegate),
layer_(NULL),
parent_(NULL),
@@ -75,12 +76,19 @@ Window::~Window() {
root_window->OnWindowDestroying(this);
// Then destroy the children.
- while (!children_.empty()) {
+ size_t child_count = children_.size();
+ while (child_count-- > 0) {
Window* child = children_[0];
- delete child;
- // Deleting the child so remove it from out children_ list.
- DCHECK(std::find(children_.begin(), children_.end(), child) ==
- children_.end());
+ if (child->owned_by_parent_) {
+ delete child;
+ // Deleting the child so remove it from out children_ list.
+ DCHECK(std::find(children_.begin(), children_.end(), child) ==
+ children_.end());
+ } else {
+ // We don't call SetParent() since that may do unexpected things like
+ // reparent the window.
+ child->parent_ = NULL;
+ }
}
// Removes ourselves from our transient parent (if it hasn't been done by the