Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Unified Diff: ash/common/system/status_area_widget.cc

Issue 2557593009: Fix Chrome crashes on calling OnTrayVisibilityChange (Closed)
Patch Set: address comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/system/status_area_widget.h ('k') | ash/common/system/tray/system_tray_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/status_area_widget.cc
diff --git a/ash/common/system/status_area_widget.cc b/ash/common/system/status_area_widget.cc
index 06bdf90c0d2c21eceda997e746f013cf09ae213d..e854f7b1b6dd65272c6910d1bb42d1eeeb62bdc2 100644
--- a/ash/common/system/status_area_widget.cc
+++ b/ash/common/system/status_area_widget.cc
@@ -43,7 +43,8 @@ StatusAreaWidget::StatusAreaWidget(WmWindow* status_container,
ime_menu_tray_(nullptr),
#endif
login_status_(LoginStatus::NOT_LOGGED_IN),
- wm_shelf_(wm_shelf) {
+ wm_shelf_(wm_shelf),
+ is_initialized_(false) {
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
params.delegate = status_area_widget_delegate_;
@@ -83,9 +84,11 @@ void StatusAreaWidget::CreateTrayViews() {
overview_button_tray_->Initialize();
SetShelfAlignment(system_tray_->shelf_alignment());
UpdateAfterLoginStatusChange(delegate->GetUserLoginStatus());
+ is_initialized_ = true;
}
void StatusAreaWidget::Shutdown() {
+ is_initialized_ = false;
system_tray_->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
@@ -148,6 +151,12 @@ void StatusAreaWidget::OnTrayVisibilityChanged(TrayBackgroundView* tray) {
if (!ash::MaterialDesignController::IsShelfMaterial())
return;
+ // StatusAreaWidget may be |Shutdown| but still be accessed before it gets
sadrul 2016/12/12 19:34:48 What is accessing this widget after Shutdown() is
yiyix 2016/12/13 17:10:38 We have discussed this problem offline. The main p
+ // reinitialized. Avoid accessing uninitialized trays.
+ if (!is_initialized_) {
+ return;
+ }
+
// No separator is required between |system_tray_| and |overview_button_tray_|
// and no separator is required for the right most tray item.
if (tray == overview_button_tray_ || tray == system_tray_) {
« no previous file with comments | « ash/common/system/status_area_widget.h ('k') | ash/common/system/tray/system_tray_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698