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

Unified Diff: ash/display/display_controller.cc

Issue 520273002: Make sure primary root window is deleted last. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 6 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_controller.cc
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index 4fb77b8f7cf314f6006101954daf39a30e45b4bb..173b2b7f9cf769ec529bb233e6b85a4ec3885638 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -25,6 +25,7 @@
#include "ash/shell_delegate.h"
#include "ash/wm/coordinate_conversion.h"
#include "base/command_line.h"
+#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/aura/client/capture_client.h"
@@ -266,17 +267,27 @@ void DisplayController::Shutdown() {
virtual_keyboard_window_controller_.reset();
Shell::GetScreen()->RemoveObserver(this);
- // Delete all root window controllers, which deletes root window
- // from the last so that the primary root window gets deleted last.
oshima 2014/08/30 00:50:36 This comment was wrong, although deleting primary
- for (WindowTreeHostMap::const_reverse_iterator it =
- window_tree_hosts_.rbegin();
- it != window_tree_hosts_.rend();
- ++it) {
- RootWindowController* controller =
- GetRootWindowController(GetWindow(it->second));
- DCHECK(controller);
- delete controller;
+
+ int64 primary_id = Shell::GetScreen()->GetPrimaryDisplay().id();
+
+ // Delete non primary root window controllers first, then
+ // delete the primary root window controller.
+ aura::Window::Windows root_windows = DisplayController::GetAllRootWindows();
+ std::vector<RootWindowController*> to_delete;
+ RootWindowController* primary_rwc = NULL;
+ for (aura::Window::Windows::iterator iter = root_windows.begin();
+ iter != root_windows.end();
+ ++iter) {
+ RootWindowController* rwc = GetRootWindowController(*iter);
+ if (GetRootWindowSettings(*iter)->display_id == primary_id)
+ primary_rwc = rwc;
+ else
+ to_delete.push_back(rwc);
}
+ CHECK(primary_rwc);
+
+ STLDeleteElements(&to_delete);
+ delete primary_rwc;
}
void DisplayController::CreatePrimaryHost(
@@ -325,7 +336,7 @@ aura::Window* DisplayController::GetPrimaryRootWindow() {
}
aura::Window* DisplayController::GetRootWindowForDisplayId(int64 id) {
- DCHECK_EQ(1u, window_tree_hosts_.count(id));
+ CHECK_EQ(1u, window_tree_hosts_.count(id));
oshima 2014/08/30 00:50:36 I changed to CHECK to catch the error early in rel
AshWindowTreeHost* host = window_tree_hosts_[id];
CHECK(host);
return GetWindow(host);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698