summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-24 01:17:35 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-24 01:17:35 +0000
commitacd50cd768ebb91804dc40aa6f66fe5cb9bdcfbc (patch)
tree6b368a69668e47600bac6e0c5a5e71fc9a27d723 /ash
parent475dbf8b68ff344c84affa29ed38bd8979292958 (diff)
downloadchromium_src-acd50cd768ebb91804dc40aa6f66fe5cb9bdcfbc.zip
chromium_src-acd50cd768ebb91804dc40aa6f66fe5cb9bdcfbc.tar.gz
chromium_src-acd50cd768ebb91804dc40aa6f66fe5cb9bdcfbc.tar.bz2
ash: Avoid crash when returning from network details popup.
r128551 changed some Close() calls in SystemTray to CloseNow(), resulting in a segfault when switching from the network details popup back to the main system tray popup. This undoes that change and fixes some related code. The reason for the CloseNow() change was because I was otherwise seeing the volume control be missing from the default popup if I hit F10 first and then clicked the system tray. The reason for this is because TrayVolume just uses a single view, and TrayVolume::DestroyDetailedView() didn't check to make sure that the view that it was destroying wasn't actually being used for the default popup. We'd create a new view for the default popup, but then the detailed popup would get closed afterwards and kill it. BUG=119858 TEST=manual Review URL: https://chromiumcodereview.appspot.com/9849001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128632 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/system/audio/tray_volume.cc10
-rw-r--r--ash/system/audio/tray_volume.h5
-rw-r--r--ash/system/tray/system_tray.cc7
3 files changed, 17 insertions, 5 deletions
diff --git a/ash/system/audio/tray_volume.cc b/ash/system/audio/tray_volume.cc
index c3f66d1..f23b525 100644
--- a/ash/system/audio/tray_volume.cc
+++ b/ash/system/audio/tray_volume.cc
@@ -167,7 +167,7 @@ class VolumeView : public views::View,
} // namespace tray
-TrayVolume::TrayVolume() {
+TrayVolume::TrayVolume() : is_default_view_(false) {
}
TrayVolume::~TrayVolume() {
@@ -179,11 +179,13 @@ views::View* TrayVolume::CreateTrayView(user::LoginStatus status) {
views::View* TrayVolume::CreateDefaultView(user::LoginStatus status) {
volume_view_.reset(new tray::VolumeView);
+ is_default_view_ = true;
return volume_view_.get();
}
views::View* TrayVolume::CreateDetailedView(user::LoginStatus status) {
volume_view_.reset(new tray::VolumeView);
+ is_default_view_ = false;
return volume_view_.get();
}
@@ -191,11 +193,13 @@ void TrayVolume::DestroyTrayView() {
}
void TrayVolume::DestroyDefaultView() {
- volume_view_.reset();
+ if (is_default_view_)
+ volume_view_.reset();
}
void TrayVolume::DestroyDetailedView() {
- volume_view_.reset();
+ if (!is_default_view_)
+ volume_view_.reset();
}
void TrayVolume::OnVolumeChanged(float percent) {
diff --git a/ash/system/audio/tray_volume.h b/ash/system/audio/tray_volume.h
index 8a2f0e3..54da195 100644
--- a/ash/system/audio/tray_volume.h
+++ b/ash/system/audio/tray_volume.h
@@ -37,6 +37,11 @@ class TrayVolume : public SystemTrayItem,
scoped_ptr<tray::VolumeView> volume_view_;
+ // Was |volume_view_| created for CreateDefaultView() rather than
+ // CreateDetailedView()? Used to avoid resetting |volume_view_|
+ // inappropriately in DestroyDefaultView() or DestroyDetailedView().
+ bool is_default_view_;
+
DISALLOW_COPY_AND_ASSIGN(TrayVolume);
};
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 42e422d..0420470 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -131,6 +131,9 @@ class TrayPopupItemContainer : public views::View {
}
virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE {
+ if (child_count() == 0)
+ return;
+
views::View* view = child_at(0);
if (!view->background()) {
canvas->FillRect(gfx::Rect(size()),
@@ -472,7 +475,7 @@ void SystemTray::RemoveTrayItem(SystemTrayItem* item) {
void SystemTray::ShowDefaultView() {
if (popup_) {
popup_->RemoveObserver(this);
- popup_->CloseNow();
+ popup_->Close();
}
popup_ = NULL;
bubble_ = NULL;
@@ -485,7 +488,7 @@ void SystemTray::ShowDetailedView(SystemTrayItem* item,
bool activate) {
if (popup_) {
popup_->RemoveObserver(this);
- popup_->CloseNow();
+ popup_->Close();
}
popup_ = NULL;
bubble_ = NULL;