Commit fe89c29e authored by jamescook's avatar jamescook Committed by Commit bot

chromeos: Fix shutdown crash in status area teardown on stylus devices

StatusAreaWidget::Shutdown() needs to manually remove all its child view to
avoid layout problems during shutdown. The stylus palette tray view wasn't
being removed.

This should fix a crash in aura::WindowEventDispatcher::ReleaseNativeCapture
during ash::Shell teardown that we're seeing on kevin.

I added a DCHECK to ensure all views are being cleaned up and filed a bug
to refactor this code so we don't have to clean up the views manually.

Fixed FocusCycleTest so it doesn't add duplicate child views to the status
area, which was tripping my DCHECK.

BUG=700122

Review-Url: https://codereview.chromium.org/2745723002
Cr-Commit-Position: refs/heads/master@{#456104}
parent 9d7a165c
......@@ -82,6 +82,10 @@ void StatusAreaWidget::Shutdown() {
// Destroy the trays early, causing them to be removed from the view
// hierarchy. Do not used scoped pointers since we don't want to destroy them
// in the destructor if Shutdown() is not called (e.g. in tests).
// Failure to remove the tray views causes layout crashes during shutdown,
// for example http://crbug.com/700122.
// TODO(jamescook): Find a better way to avoid the layout problems, fix the
// tests and switch to std::unique_ptr. http://crbug.com/700255
delete web_notification_tray_;
web_notification_tray_ = nullptr;
// Must be destroyed after |web_notification_tray_|.
......@@ -91,10 +95,14 @@ void StatusAreaWidget::Shutdown() {
ime_menu_tray_ = nullptr;
delete virtual_keyboard_tray_;
virtual_keyboard_tray_ = nullptr;
delete palette_tray_;
palette_tray_ = nullptr;
delete logout_button_tray_;
logout_button_tray_ = nullptr;
delete overview_button_tray_;
overview_button_tray_ = nullptr;
// All child tray views have been removed.
DCHECK_EQ(0, GetContentsView()->child_count());
}
void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) {
......
......@@ -13,7 +13,6 @@
#include "ash/common/system/tray/system_tray.h"
#include "ash/common/wm_shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/status_area_widget_test_helper.h"
#include "ash/wm/window_util.h"
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
......@@ -79,12 +78,8 @@ class FocusCyclerTest : public AshTestBase {
}
protected:
// Setup the system tray using StatusAreaWidgetTestHelper and focus_cycler.
// Setup the system tray focus cycler.
void SetUpTrayFocusCycle() {
StatusAreaWidget* widget =
StatusAreaWidgetTestHelper::GetStatusAreaWidget();
widget->CreateTrayViews();
widget->Show();
views::Widget* system_tray_widget = GetPrimarySystemTray()->GetWidget();
ASSERT_TRUE(system_tray_widget);
focus_cycler_->AddWidget(system_tray_widget);
......
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