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

Unified Diff: chrome/browser/chrome_application_mac.mm

Issue 259001: [Mac] Don't crash when selecting closed window from Dock menu. (Closed)
Patch Set: Don't use -containsObject: in case it messages |aTarget|. Created 11 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_application_mac.mm
diff --git a/chrome/browser/chrome_application_mac.mm b/chrome/browser/chrome_application_mac.mm
index 8c7d86014781eb42b8e6523f939fb92ebd349c69..a94d3aac93e1ead66cf62586da73bee921eae574 100644
--- a/chrome/browser/chrome_application_mac.mm
+++ b/chrome/browser/chrome_application_mac.mm
@@ -58,4 +58,29 @@
// own.
}
+- (BOOL)sendAction:(SEL)anAction to:(id)aTarget from:(id)sender {
+ // The Dock menu contains an automagic section where you can select
+ // amongst open windows. If a window is closed via JavaScript while
+ // the menu is up, the menu item for that window continues to exist.
+ // When a window is selected this method is called with the
+ // now-freed window as |aTarget|. Short-circuit the call if
+ // |aTarget| is not a valid window.
+ if (anAction == @selector(_selectWindow:)) {
+ // Not using -[NSArray containsObject:] because |aTarget| may be a
+ // freed object.
+ BOOL found = NO;
+ for (NSWindow* window in [self windows]) {
+ if (window == aTarget) {
+ found = YES;
+ break;
+ }
+ }
+ if (!found) {
+ return NO;
+ }
+ }
+
+ return [super sendAction:anAction to:aTarget from:sender];
+}
+
@end
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698