diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-20 11:37:34 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-20 11:37:34 +0000 |
commit | 28b5556eb282296431ad6122d5eccb95141f8550 (patch) | |
tree | 6ddbe1653845829ff97b6d2fac8a317b20327248 /ash | |
parent | 922307f6970b1d83bb12597ff94c36d3a4f99ae2 (diff) | |
download | chromium_src-28b5556eb282296431ad6122d5eccb95141f8550.zip chromium_src-28b5556eb282296431ad6122d5eccb95141f8550.tar.gz chromium_src-28b5556eb282296431ad6122d5eccb95141f8550.tar.bz2 |
Fix dependency on scoped_ptr::reset sequencing in ash::DisplayController
scoped_ptr<T>::reset() currently guarantees that it deletes the old
stored pointer before assigning its argument to the stored pointer.
This is unsafe, because getting the deleter may result in the
destruction of the scoped_ptr<T> itself. unique_ptr<T> addresses this by
assigning its argument to the stored pointer before deleting the old
value of the stored pointer.
Unfortunately, this breaks code that assumes that the value of the
scoped_ptr will not change during scoped_ptr::reset() before destruction
of the old value is complete.
BUG=176091
Review URL: https://chromiumcodereview.appspot.com/12296033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/display/display_controller.cc | 5 | ||||
-rw-r--r-- | ash/display/display_controller.h | 4 | ||||
-rw-r--r-- | ash/shell.cc | 5 |
3 files changed, 12 insertions, 2 deletions
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc index 5bdca9b..2d645a1 100644 --- a/ash/display/display_controller.cc +++ b/ash/display/display_controller.cc @@ -254,6 +254,10 @@ DisplayController::DisplayController() } DisplayController::~DisplayController() { + DCHECK(primary_display_for_shutdown); +} + +void DisplayController::Shutdown() { DCHECK(!primary_display_for_shutdown); primary_display_for_shutdown = new gfx::Display( GetDisplayManager()->GetDisplayForId(primary_display_id)); @@ -270,6 +274,7 @@ DisplayController::~DisplayController() { delete controller; } } + // static const gfx::Display& DisplayController::GetPrimaryDisplay() { DCHECK_NE(primary_display_id, gfx::Display::kInvalidDisplayID); diff --git a/ash/display/display_controller.h b/ash/display/display_controller.h index 17b9eb0..2674483 100644 --- a/ash/display/display_controller.h +++ b/ash/display/display_controller.h @@ -84,7 +84,9 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver { DisplayController(); virtual ~DisplayController(); - // Retruns primary display. This is safe to use after ash::Shell is + void Shutdown(); + + // Returns primary display. This is safe to use after ash::Shell is // deleted. static const gfx::Display& GetPrimaryDisplay(); diff --git a/ash/shell.cc b/ash/shell.cc index cd317d7..1a386ea 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -288,7 +288,10 @@ Shell::~Shell() { power_button_controller_.reset(); session_state_controller_.reset(); - // This also deletes all RootWindows. + // This also deletes all RootWindows. Note that we invoke Shutdown() on + // DisplayController before resetting |display_controller_|, since destruction + // of its owned RootWindowControllers relies on the value. + display_controller_->Shutdown(); display_controller_.reset(); screen_position_controller_.reset(); |