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

Unified Diff: views/controls/button/menu_button.cc

Issue 1664001: Fixes possible crash if the window hosting a menu was closed while the (Closed)
Patch Set: Incorporated review feedback Created 10 years, 8 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 | « views/controls/button/menu_button.h ('k') | views/controls/menu/menu_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/button/menu_button.cc
diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc
index 4a1e28ab4fd9e72136ce2f23fba3fc5f0801e72b..b45c2acfdddda3d19ed89b839a7e6e9d8db571ee 100644
--- a/views/controls/button/menu_button.cc
+++ b/views/controls/button/menu_button.cc
@@ -49,11 +49,14 @@ MenuButton::MenuButton(ButtonListener* listener,
menu_delegate_(menu_delegate),
show_menu_marker_(show_menu_marker),
menu_marker_(ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_MENU_DROPARROW)) {
+ IDR_MENU_DROPARROW)),
+ destroyed_flag_(NULL) {
set_alignment(TextButton::ALIGN_LEFT);
}
MenuButton::~MenuButton() {
+ if (destroyed_flag_)
+ *destroyed_flag_ = true;
}
////////////////////////////////////////////////////////////////////////////////
@@ -145,7 +148,17 @@ bool MenuButton::Activate() {
GetRootView()->SetMouseHandler(NULL);
menu_visible_ = true;
+
+ bool destroyed = false;
+ destroyed_flag_ = &destroyed;
+
menu_delegate_->RunMenu(this, menu_position);
+
+ if (destroyed) {
+ // The menu was deleted while showing. Don't attempt any processing.
+ return false;
+ }
+
menu_visible_ = false;
menu_closed_time_ = Time::Now();
« no previous file with comments | « views/controls/button/menu_button.h ('k') | views/controls/menu/menu_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698