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

Side by Side 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, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/chrome_application_mac.h" 5 #import "chrome/browser/chrome_application_mac.h"
6 6
7 @implementation CrApplication 7 @implementation CrApplication
8 8
9 // -terminate: is the entry point for orderly "quit" operations in Cocoa. 9 // -terminate: is the entry point for orderly "quit" operations in Cocoa.
10 // This includes the application menu's quit menu item and keyboard 10 // This includes the application menu's quit menu item and keyboard
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 return; 51 return;
52 52
53 [[NSNotificationCenter defaultCenter] 53 [[NSNotificationCenter defaultCenter]
54 postNotificationName:NSApplicationWillTerminateNotification 54 postNotificationName:NSApplicationWillTerminateNotification
55 object:self]; 55 object:self];
56 56
57 // Return, don't exit. The application is responsible for exiting on its 57 // Return, don't exit. The application is responsible for exiting on its
58 // own. 58 // own.
59 } 59 }
60 60
61 - (BOOL)sendAction:(SEL)anAction to:(id)aTarget from:(id)sender {
62 // The Dock menu contains an automagic section where you can select
63 // amongst open windows. If a window is closed via JavaScript while
64 // the menu is up, the menu item for that window continues to exist.
65 // When a window is selected this method is called with the
66 // now-freed window as |aTarget|. Short-circuit the call if
67 // |aTarget| is not a valid window.
68 if (anAction == @selector(_selectWindow:)) {
69 // Not using -[NSArray containsObject:] because |aTarget| may be a
70 // freed object.
71 BOOL found = NO;
72 for (NSWindow* window in [self windows]) {
73 if (window == aTarget) {
74 found = YES;
75 break;
76 }
77 }
78 if (!found) {
79 return NO;
80 }
81 }
82
83 return [super sendAction:anAction to:aTarget from:sender];
84 }
85
61 @end 86 @end
OLDNEW
« 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