Commit ef589afc authored by oshima@chromium.org's avatar oshima@chromium.org

Delete desktop/shell instance correctly upon shutdown.

* Moved parts->PostMainMessageLoopRun call from PostDestroyThreads to the right place (PostMainMessageLoopRun() method)
* Renamed Shell::DeleteInstanceForTesting to DeleteInstance as this is no longer for testing.

BUG=106070
TEST=browser_tests on aura will not crash as described in the bug

Review URL: http://codereview.chromium.org/8774029

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112836 0039d316-1c4b-4281-b951-d872f2087c98
parent ede5e61a
......@@ -2002,6 +2002,9 @@ void ChromeBrowserMainParts::PostMainMessageLoopRun() {
// Disarm the startup hang detector time bomb if it is still Arm'ed.
startup_watcher_->Disarm();
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PostMainMessageLoopRun();
#if defined(OS_WIN)
// If it's the first run, log the search engine chosen. We wait until
// shutdown because otherwise we can't be sure the user has finished
......@@ -2102,9 +2105,6 @@ void ChromeBrowserMainParts::PostDestroyThreads() {
// to bypass this code. Perhaps we need a *final* hook that is called on all
// paths from content/browser/browser_main.
CHECK(MetricsService::UmaMetricsProperlyShutdown());
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PostMainMessageLoopRun();
}
// Public members:
......
......@@ -28,3 +28,8 @@ void ChromeBrowserMainExtraPartsAura::PostBrowserProcessInit() {
// Make sure the singleton ScreenOrientationListener object is created.
ScreenOrientationListener::GetInstance();
}
void ChromeBrowserMainExtraPartsAura::PostMainMessageLoopRun() {
aura_shell::Shell::DeleteInstance();
aura::Desktop::DeleteInstance();
}
......@@ -14,6 +14,7 @@ class ChromeBrowserMainExtraPartsAura : public ChromeBrowserMainExtraParts {
ChromeBrowserMainExtraPartsAura();
virtual void PostBrowserProcessInit() OVERRIDE;
virtual void PostMainMessageLoopRun() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsAura);
......
......@@ -592,7 +592,7 @@ void DesktopHostLinux::PostNativeEvent(const base::NativeEvent& native_event) {
}
void DesktopHostLinux::WillDestroyCurrentMessageLoop() {
desktop_->DeleteInstance();
aura::Desktop::DeleteInstance();
}
bool DesktopHostLinux::IsWindowManagerPresent() {
......
......@@ -35,7 +35,8 @@ ShelfLayoutController::ShelfLayoutController(views::Widget* launcher,
}
ShelfLayoutController::~ShelfLayoutController() {
GetLayer(launcher_)->GetAnimator()->RemoveObserver(this);
// Do not try to remove observer from layer as the Launcher is
// already deleted.
}
void ShelfLayoutController::LayoutShelf() {
......
......@@ -127,6 +127,21 @@ Shell::~Shell() {
RemoveDesktopEventFilter(tooltip_manager_.get());
aura::Desktop::GetInstance()->SetProperty(aura::kDesktopTooltipClientKey,
NULL);
// Make sure we delete WorkspaceController before launcher is
// deleted as it has a reference to launcher model.
workspace_controller_.reset();
launcher_.reset();
// Delete containers now so that child windows does not access
// observers when they are destructed. This has to be after launcher
// is destructed because launcher closes the widget in its destructor.
aura::Desktop* desktop_window = aura::Desktop::GetInstance();
while (!desktop_window->children().empty()) {
aura::Window* child = desktop_window->children()[0];
delete child;
}
tooltip_manager_.reset();
// Drag drop controller needs a valid shell instance. We destroy it first.
......@@ -134,10 +149,6 @@ Shell::~Shell() {
DCHECK(instance_ == this);
instance_ = NULL;
// Make sure we delete WorkspaceController before launcher is
// deleted as it has a reference to launcher model.
workspace_controller_.reset();
}
// static
......@@ -155,7 +166,7 @@ Shell* Shell::GetInstance() {
}
// static
void Shell::DeleteInstanceForTesting() {
void Shell::DeleteInstance() {
delete instance_;
instance_ = NULL;
}
......
......@@ -54,7 +54,7 @@ class AURA_SHELL_EXPORT Shell {
// Should never be called before |CreateInstance()|.
static Shell* GetInstance();
static void DeleteInstanceForTesting();
static void DeleteInstance();
aura::Window* GetContainer(int container_id);
const aura::Window* GetContainer(int container_id) const;
......
......@@ -27,7 +27,7 @@ void AuraShellTestBase::TearDown() {
RunAllPendingInMessageLoop();
// Tear down the shell.
aura_shell::Shell::DeleteInstanceForTesting();
aura_shell::Shell::DeleteInstance();
aura::test::AuraTestBase::TearDown();
}
......
......@@ -372,10 +372,10 @@ void NativeWidgetAura::Close() {
// and ownership is WIDGET_OWNS_NATIVE_WIDGET.
DCHECK(window_ ||
ownership_ == Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET);
if (window_)
if (window_) {
Hide();
window_->SetIntProperty(aura::kModalKey, 0);
}
if (!close_widget_factory_.HasWeakPtrs()) {
MessageLoop::current()->PostTask(
......
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