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

Unified Diff: ui/views/controls/menu/menu_pre_target_handler.cc

Issue 2208113002: Fix MenuPreTargetHandler Crash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months 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 | « ui/views/controls/menu/menu_controller_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/menu/menu_pre_target_handler.cc
diff --git a/ui/views/controls/menu/menu_pre_target_handler.cc b/ui/views/controls/menu/menu_pre_target_handler.cc
index 97cceb3104d761a8c24dfbc690743b5c41035f72..7ac7a3f5b474d2423683bbf287947b3f472d89eb 100644
--- a/ui/views/controls/menu/menu_pre_target_handler.cc
+++ b/ui/views/controls/menu/menu_pre_target_handler.cc
@@ -24,11 +24,14 @@ MenuPreTargetHandler::MenuPreTargetHandler(MenuController* controller,
Widget* owner)
: controller_(controller), root_(GetOwnerRootWindow(owner)) {
aura::Env::GetInstanceDontCreate()->PrependPreTargetHandler(this);
- aura::client::GetActivationClient(root_)->AddObserver(this);
- root_->AddObserver(this);
+ if (root_) {
+ aura::client::GetActivationClient(root_)->AddObserver(this);
+ root_->AddObserver(this);
+ }
}
MenuPreTargetHandler::~MenuPreTargetHandler() {
+ aura::Env::GetInstanceDontCreate()->RemovePreTargetHandler(this);
Cleanup();
}
@@ -55,7 +58,6 @@ void MenuPreTargetHandler::OnKeyEvent(ui::KeyEvent* event) {
void MenuPreTargetHandler::Cleanup() {
if (!root_)
return;
- aura::Env::GetInstanceDontCreate()->RemovePreTargetHandler(this);
// The ActivationClient may have been destroyed by the time we get here.
aura::client::ActivationClient* client =
aura::client::GetActivationClient(root_);
« no previous file with comments | « ui/views/controls/menu/menu_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698