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

Side by Side Diff: ash/wm/window_cycle_list.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 | « ash/wm/solo_window_tracker_unittest.cc ('k') | ash/wm/window_state.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 "ash/wm/window_cycle_list.h" 5 #include "ash/wm/window_cycle_list.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/wm/mru_window_tracker.h" 8 #include "ash/wm/mru_window_tracker.h"
9 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 int WindowCycleList::GetWindowIndex(aura::Window* window) { 66 int WindowCycleList::GetWindowIndex(aura::Window* window) {
67 WindowList::const_iterator it = 67 WindowList::const_iterator it =
68 std::find(windows_.begin(), windows_.end(), window); 68 std::find(windows_.begin(), windows_.end(), window);
69 if (it == windows_.end()) 69 if (it == windows_.end())
70 return -1; // Not found. 70 return -1; // Not found.
71 return it - windows_.begin(); 71 return it - windows_.begin();
72 } 72 }
73 73
74 void WindowCycleList::OnWindowDestroyed(aura::Window* window) { 74 void WindowCycleList::OnWindowDestroyed(aura::Window* window) {
75 window->RemoveObserver(this);
76
77 WindowList::iterator i = std::find(windows_.begin(), windows_.end(), window); 75 WindowList::iterator i = std::find(windows_.begin(), windows_.end(), window);
78 DCHECK(i != windows_.end()); 76 DCHECK(i != windows_.end());
79 int removed_index = static_cast<int>(i - windows_.begin()); 77 int removed_index = static_cast<int>(i - windows_.begin());
80 windows_.erase(i); 78 windows_.erase(i);
81 if (current_index_ > removed_index) 79 if (current_index_ > removed_index)
82 current_index_--; 80 current_index_--;
83 else if (current_index_ == static_cast<int>(windows_.size())) 81 else if (current_index_ == static_cast<int>(windows_.size()))
84 current_index_--; 82 current_index_--;
85 } 83 }
86 84
87 } // namespace ash 85 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/solo_window_tracker_unittest.cc ('k') | ash/wm/window_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698