From fce1e4720e5398d09f315ca51b94ace81cf9b774 Mon Sep 17 00:00:00 2001 From: "oshima@chromium.org" Date: Fri, 6 Dec 2013 18:08:37 +0000 Subject: Revert 239232 "Make sure WindowObservers are removed from window..." > Make sure WindowObservers are removed from window before destruction > > * Check if the window observer is empty upon destruction. > * remove the all observers in ~WindowObserver() > * Remove RemoveObserver that are no longer necessary > * Fix shell shutdown order so that observers are removed correctly before deleting all windows. > > BUG=324018 > R=skuhne@chromium.org, sky@chromium.org > > Review URL: https://codereview.chromium.org/101013002 TBR=oshima@chromium.org Review URL: https://codereview.chromium.org/103863003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239239 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/aura/client/default_activation_client.cc | 1 + ui/aura/window.cc | 7 +------ ui/aura/window.h | 2 +- ui/aura/window_observer.h | 10 ++-------- 4 files changed, 5 insertions(+), 15 deletions(-) (limited to 'ui/aura') diff --git a/ui/aura/client/default_activation_client.cc b/ui/aura/client/default_activation_client.cc index ccb660b..629f12a 100644 --- a/ui/aura/client/default_activation_client.cc +++ b/ui/aura/client/default_activation_client.cc @@ -102,6 +102,7 @@ void DefaultActivationClient::OnWindowDestroyed(Window* window) { last_active_ = NULL; if (window == GetActiveWindow()) { + window->RemoveObserver(this); active_windows_.pop_back(); Window* next_active = GetActiveWindow(); if (next_active && aura::client::GetActivationChangeObserver(next_active)) { diff --git a/ui/aura/window.cc b/ui/aura/window.cc index 2655b8a..692e345 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -168,12 +168,7 @@ Window::~Window() { // Delegate and observers need to be notified after transients are deleted. if (delegate_) delegate_->OnWindowDestroyed(); - ObserverListBase::Iterator iter(observers_); - WindowObserver* observer; - while ((observer = iter.GetNext())) { - RemoveObserver(observer); - observer->OnWindowDestroyed(this); - } + FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowDestroyed(this)); // Clear properties. for (std::map::const_iterator iter = prop_map_.begin(); diff --git a/ui/aura/window.h b/ui/aura/window.h index c6dcd09..f2a5672 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h @@ -588,7 +588,7 @@ class AURA_EXPORT Window : public ui::LayerDelegate, gfx::Insets hit_test_bounds_override_outer_touch_; gfx::Insets hit_test_bounds_override_inner_; - ObserverList observers_; + ObserverList observers_; // Value struct to keep the name and deallocator for this property. // Key cannot be used for this purpose because it can be char* or diff --git a/ui/aura/window_observer.h b/ui/aura/window_observer.h index 9408ee8..5008ac5 100644 --- a/ui/aura/window_observer.h +++ b/ui/aura/window_observer.h @@ -87,14 +87,8 @@ class AURA_EXPORT WindowObserver { // destructor). This is called before the window is removed from its parent. virtual void OnWindowDestroying(Window* window) {} - // Invoked when the Window has been destroyed (i.e. at the end of - // its destructor). This is called after the window is removed from - // its parent. Window automatically removes its WindowObservers - // before calling this method, so the following code is no op. - // - // void MyWindowObserver::OnWindowDestroyed(aura::Window* window) { - // window->RemoveObserver(this); - // } + // Invoked when the Window has been destroyed (i.e. at the end of its + // destructor). This is called after the window is removed from its parent. virtual void OnWindowDestroyed(Window* window) {} // Called when a Window has been added to a RootWindow. -- cgit v1.1