Commit 892f21f9 authored by oshima's avatar oshima Committed by Commit bot

Make sure primary root window is deleted last.

BUG=403380
R=mukai@chromium.org

Review URL: https://codereview.chromium.org/520273002

Cr-Commit-Position: refs/heads/master@{#292759}
parent ce634e9b
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "ash/shell_delegate.h" #include "ash/shell_delegate.h"
#include "ash/wm/coordinate_conversion.h" #include "ash/wm/coordinate_conversion.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "ui/aura/client/capture_client.h" #include "ui/aura/client/capture_client.h"
...@@ -266,17 +267,27 @@ void DisplayController::Shutdown() { ...@@ -266,17 +267,27 @@ void DisplayController::Shutdown() {
virtual_keyboard_window_controller_.reset(); virtual_keyboard_window_controller_.reset();
Shell::GetScreen()->RemoveObserver(this); 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. int64 primary_id = Shell::GetScreen()->GetPrimaryDisplay().id();
for (WindowTreeHostMap::const_reverse_iterator it =
window_tree_hosts_.rbegin(); // Delete non primary root window controllers first, then
it != window_tree_hosts_.rend(); // delete the primary root window controller.
++it) { aura::Window::Windows root_windows = DisplayController::GetAllRootWindows();
RootWindowController* controller = std::vector<RootWindowController*> to_delete;
GetRootWindowController(GetWindow(it->second)); RootWindowController* primary_rwc = NULL;
DCHECK(controller); for (aura::Window::Windows::iterator iter = root_windows.begin();
delete controller; 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( void DisplayController::CreatePrimaryHost(
...@@ -325,7 +336,7 @@ aura::Window* DisplayController::GetPrimaryRootWindow() { ...@@ -325,7 +336,7 @@ aura::Window* DisplayController::GetPrimaryRootWindow() {
} }
aura::Window* DisplayController::GetRootWindowForDisplayId(int64 id) { aura::Window* DisplayController::GetRootWindowForDisplayId(int64 id) {
DCHECK_EQ(1u, window_tree_hosts_.count(id)); CHECK_EQ(1u, window_tree_hosts_.count(id));
AshWindowTreeHost* host = window_tree_hosts_[id]; AshWindowTreeHost* host = window_tree_hosts_[id];
CHECK(host); CHECK(host);
return GetWindow(host); return GetWindow(host);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment