| Index: ui/aura/mus/focus_synchronizer.cc
|
| diff --git a/ui/aura/mus/focus_synchronizer.cc b/ui/aura/mus/focus_synchronizer.cc
|
| index b211315fc9ca0c97d991b01993559d1fe0cd4d51..4c24ccc10316df90d0231170a12114e0d7d3448f 100644
|
| --- a/ui/aura/mus/focus_synchronizer.cc
|
| +++ b/ui/aura/mus/focus_synchronizer.cc
|
| @@ -16,13 +16,16 @@ namespace aura {
|
|
|
| FocusSynchronizer::FocusSynchronizer(FocusSynchronizerDelegate* delegate,
|
| ui::mojom::WindowTree* window_tree)
|
| - : delegate_(delegate), window_tree_(window_tree) {
|
| - Env::GetInstance()->AddObserver(this);
|
| + : delegate_(delegate), window_tree_(window_tree), env_(Env::GetInstance()) {
|
| + DCHECK(env_);
|
| + env_->AddObserver(this);
|
| }
|
|
|
| FocusSynchronizer::~FocusSynchronizer() {
|
| - SetActiveFocusClient(nullptr);
|
| - Env::GetInstance()->RemoveObserver(this);
|
| + if (env_) {
|
| + SetActiveFocusClient(nullptr);
|
| + env_->RemoveObserver(this);
|
| + }
|
| }
|
|
|
| void FocusSynchronizer::SetFocusFromServer(WindowMus* window) {
|
| @@ -81,6 +84,12 @@ void FocusSynchronizer::OnWindowFocused(Window* gained_focus,
|
|
|
| void FocusSynchronizer::OnWindowInitialized(Window* window) {}
|
|
|
| +void FocusSynchronizer::OnWillDestroyEnv() {
|
| + SetActiveFocusClient(nullptr);
|
| + env_->RemoveObserver(this);
|
| + env_ = nullptr;
|
| +}
|
| +
|
| void FocusSynchronizer::OnActiveFocusClientChanged(
|
| client::FocusClient* focus_client,
|
| Window* window) {
|
|
|