Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(744)

Side by Side Diff: ui/aura/window.cc

Issue 101013002: Make sure WindowObservers are removed from window before destruction (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix shutdown order Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // Destroy transient children, only after we've removed ourselves from our 161 // Destroy transient children, only after we've removed ourselves from our
162 // parent, as destroying an active transient child may otherwise attempt to 162 // parent, as destroying an active transient child may otherwise attempt to
163 // refocus us. 163 // refocus us.
164 Windows transient_children(transient_children_); 164 Windows transient_children(transient_children_);
165 STLDeleteElements(&transient_children); 165 STLDeleteElements(&transient_children);
166 DCHECK(transient_children_.empty()); 166 DCHECK(transient_children_.empty());
167 167
168 // Delegate and observers need to be notified after transients are deleted. 168 // Delegate and observers need to be notified after transients are deleted.
169 if (delegate_) 169 if (delegate_)
170 delegate_->OnWindowDestroyed(); 170 delegate_->OnWindowDestroyed();
171 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroyed(this)); 171 ObserverListBase<WindowObserver>::Iterator iter(observers_);
172 WindowObserver* observer;
173 while ((observer = iter.GetNext())) {
174 RemoveObserver(observer);
175 observer->OnWindowDestroyed(this);
176 }
172 177
173 // Clear properties. 178 // Clear properties.
174 for (std::map<const void*, Value>::const_iterator iter = prop_map_.begin(); 179 for (std::map<const void*, Value>::const_iterator iter = prop_map_.begin();
175 iter != prop_map_.end(); 180 iter != prop_map_.end();
176 ++iter) { 181 ++iter) {
177 if (iter->second.deallocator) 182 if (iter->second.deallocator)
178 (*iter->second.deallocator)(iter->second.value); 183 (*iter->second.deallocator)(iter->second.value);
179 } 184 }
180 prop_map_.clear(); 185 prop_map_.clear();
181 186
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 for (const aura::Window* window = this; window; window = window->parent()) { 1408 for (const aura::Window* window = this; window; window = window->parent()) {
1404 if (window->layer_) 1409 if (window->layer_)
1405 return window; 1410 return window;
1406 *offset += window->bounds().OffsetFromOrigin(); 1411 *offset += window->bounds().OffsetFromOrigin();
1407 } 1412 }
1408 *offset = gfx::Vector2d(); 1413 *offset = gfx::Vector2d();
1409 return NULL; 1414 return NULL;
1410 } 1415 }
1411 1416
1412 } // namespace aura 1417 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698