summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-27 22:35:51 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-27 22:35:51 +0000
commit301d13e7464932720554613443c79d2dea15f73f (patch)
tree70b81813047608864707f2548123cc85bd154a82 /chrome
parent0d0eea00aaedb6f5a8b9df8ee80ef30d0fe91fa2 (diff)
downloadchromium_src-301d13e7464932720554613443c79d2dea15f73f.zip
chromium_src-301d13e7464932720554613443c79d2dea15f73f.tar.gz
chromium_src-301d13e7464932720554613443c79d2dea15f73f.tar.bz2
[Mac] Prevent using tab context menu after tab closed.
JavaScript can close windows while in the event loop processing a right-click menu. This change prevents sending messages to the tab controller after it has been closed. BUG=25462, 25465 TEST=See bug for test.html. TEST=Run test.html, right-click tab, after close all items should be grayed out. TEST=Run test.html, click tab's close button and hold until tab closes. Should not crash on release. Review URL: http://codereview.chromium.org/335048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30269 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/cocoa/tab_controller.mm11
1 files changed, 11 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/tab_controller.mm b/chrome/browser/cocoa/tab_controller.mm
index 94de7cfc..0d05c5c 100644
--- a/chrome/browser/cocoa/tab_controller.mm
+++ b/chrome/browser/cocoa/tab_controller.mm
@@ -47,6 +47,17 @@
}
- (void)dealloc {
+ // Since the tab can be closed from JavaScript it is possible for
+ // |contextMenu_| to remain visible after the tab has closed, or for
+ // |closeButton_| to be tracking the mouse. Make sure neither sends
+ // us an action after -dealloc.
+ [closeButton_ setTarget:nil];
+ [contextMenu_ setAutoenablesItems:NO];
+ for (NSMenuItem* item in [contextMenu_ itemArray]) {
+ [item setTarget:nil];
+ [item setEnabled:NO];
+ }
+
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}