summaryrefslogtreecommitdiffstats
path: root/ash/root_window_controller.cc
diff options
context:
space:
mode:
authormukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-20 14:36:30 +0000
committermukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-20 14:36:30 +0000
commit8b3e3d8f101deab32cc3482ad752e99802efe109 (patch)
treed626c4996af36620d5a03257429343c5bfb2c2df /ash/root_window_controller.cc
parent3e639f9cd52f6a85e513e417deeb2d8733ba9423 (diff)
downloadchromium_src-8b3e3d8f101deab32cc3482ad752e99802efe109.zip
chromium_src-8b3e3d8f101deab32cc3482ad752e99802efe109.tar.gz
chromium_src-8b3e3d8f101deab32cc3482ad752e99802efe109.tar.bz2
Changes the order of deleting child windows at shutdown.
Instead of simply deleting depth-first, it deletes all toplevel windows first and then remove the containers. This would be safer since all of the containers exist during deleting the child windows. This change would enable to eliminate other NULL checks in ash, but it will be done in further CLs. BUG=273310 R=derat@chromium.org, oshima@chromium.org TEST=covered by the new test case Review URL: https://chromiumcodereview.appspot.com/23219004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218488 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/root_window_controller.cc')
-rw-r--r--ash/root_window_controller.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index dd23743..6e49c48 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -4,6 +4,7 @@
#include "ash/root_window_controller.h"
+#include <queue>
#include <vector>
#include "ash/ash_constants.h"
@@ -44,11 +45,13 @@
#include "base/command_line.h"
#include "base/time/time.h"
#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/client/tooltip_client.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_observer.h"
+#include "ui/aura/window_tracker.h"
#include "ui/base/hit_test.h"
#include "ui/base/models/menu_model.h"
#include "ui/gfx/screen.h"
@@ -404,6 +407,8 @@ void RootWindowController::CloseChildWindows() {
docked_layout_manager_ = NULL;
}
+ aura::client::SetDragDropClient(root_window_.get(), NULL);
+
// TODO(harrym): Remove when Status Area Widget is a child view.
shelf_->ShutdownStatusAreaWidget();
@@ -417,10 +422,26 @@ void RootWindowController::CloseChildWindows() {
workspace_controller_.reset();
aura::client::SetTooltipClient(root_window_.get(), NULL);
- while (!root_window_->children().empty()) {
- aura::Window* child = root_window_->children()[0];
- delete child;
+ // Remove all toplevel windows first.
+ std::queue<aura::Window*> non_toplevel_windows;
+ non_toplevel_windows.push(root_window_.get());
+ while (!non_toplevel_windows.empty()) {
+ aura::Window* non_toplevel_window = non_toplevel_windows.front();
+ non_toplevel_windows.pop();
+ aura::WindowTracker toplevel_windows;
+ for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) {
+ aura::Window* child = non_toplevel_window->children()[i];
+ if (child->delegate())
+ toplevel_windows.Add(child);
+ else
+ non_toplevel_windows.push(child);
+ }
+ while (!toplevel_windows.windows().empty())
+ delete *toplevel_windows.windows().begin();
}
+ // And then remove the containers.
+ while (!root_window_->children().empty())
+ delete root_window_->children()[0];
shelf_.reset(NULL);
}