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

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: addressed comments 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
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // Destroy transient children, only after we've removed ourselves from our 160 // Destroy transient children, only after we've removed ourselves from our
161 // parent, as destroying an active transient child may otherwise attempt to 161 // parent, as destroying an active transient child may otherwise attempt to
162 // refocus us. 162 // refocus us.
163 Windows transient_children(transient_children_); 163 Windows transient_children(transient_children_);
164 STLDeleteElements(&transient_children); 164 STLDeleteElements(&transient_children);
165 DCHECK(transient_children_.empty()); 165 DCHECK(transient_children_.empty());
166 166
167 // Delegate and observers need to be notified after transients are deleted. 167 // Delegate and observers need to be notified after transients are deleted.
168 if (delegate_) 168 if (delegate_)
169 delegate_->OnWindowDestroyed(); 169 delegate_->OnWindowDestroyed();
170 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroyed(this)); 170 ObserverListBase<WindowObserver>::Iterator iter(observers_);
171 WindowObserver* observer;
172 while ((observer = iter.GetNext())) {
173 RemoveObserver(observer);
174 observer->OnWindowDestroyed(this);
175 }
171 176
172 // Clear properties. 177 // Clear properties.
173 for (std::map<const void*, Value>::const_iterator iter = prop_map_.begin(); 178 for (std::map<const void*, Value>::const_iterator iter = prop_map_.begin();
174 iter != prop_map_.end(); 179 iter != prop_map_.end();
175 ++iter) { 180 ++iter) {
176 if (iter->second.deallocator) 181 if (iter->second.deallocator)
177 (*iter->second.deallocator)(iter->second.value); 182 (*iter->second.deallocator)(iter->second.value);
178 } 183 }
179 prop_map_.clear(); 184 prop_map_.clear();
180 185
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 for (const aura::Window* window = this; window; window = window->parent()) { 1388 for (const aura::Window* window = this; window; window = window->parent()) {
1384 if (window->layer_) 1389 if (window->layer_)
1385 return window; 1390 return window;
1386 *offset += window->bounds().OffsetFromOrigin(); 1391 *offset += window->bounds().OffsetFromOrigin();
1387 } 1392 }
1388 *offset = gfx::Vector2d(); 1393 *offset = gfx::Vector2d();
1389 return NULL; 1394 return NULL;
1390 } 1395 }
1391 1396
1392 } // namespace aura 1397 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698