Index: ash/display/window_tree_host_manager.cc |
diff --git a/ash/display/window_tree_host_manager.cc b/ash/display/window_tree_host_manager.cc |
index 358804ac0280a7b0ccecc20b30e24cb3c0b74b49..b562c761315c556838ff12ffd4b825157d70b1b7 100644 |
--- a/ash/display/window_tree_host_manager.cc |
+++ b/ash/display/window_tree_host_manager.cc |
@@ -328,6 +328,10 @@ int64_t WindowTreeHostManager::GetPrimaryDisplayId() { |
} |
aura::Window* WindowTreeHostManager::GetPrimaryRootWindow() { |
+ // If |primary_tree_host_for_replace_| is set, it means |primary_display_id| |
+ // is kInvalidDisplayId. |
+ if (primary_tree_host_for_replace_) |
+ return GetWindow(primary_tree_host_for_replace_); |
return GetRootWindowForDisplayId(primary_display_id); |
} |
@@ -633,6 +637,8 @@ void WindowTreeHostManager::DeleteHost(AshWindowTreeHost* host_to_delete) { |
// Delete most of root window related objects, but don't delete |
// root window itself yet because the stack may be using it. |
controller->Shutdown(); |
+ if (primary_tree_host_for_replace_ == host_to_delete) |
+ primary_tree_host_for_replace_ = nullptr; |
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, controller); |
} |