Commit e4dd0bd7 authored by erikchen's avatar erikchen Committed by Commit bot

mac: Fix Yosemite crash while attempting to open multiple files.

Attemping to open multiple files using the native Cocoa dialog causes a crash.
This CL inserts a safety check to work around it.

A Yosemite AppKit bug causes an NSWindowWillCloseNotification to be sent during
the -dealloc for a specific NSWindow. Any autoreleases sent to that window must
be drained before the window finishes -dealloc.

BUG=406944

Review URL: https://codereview.chromium.org/582103002

Cr-Commit-Position: refs/heads/master@{#295507}
parent 5d66c69d
......@@ -5,6 +5,7 @@
#import "chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h"
#include "apps/app_shim/extension_app_shim_handler_mac.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
......@@ -277,6 +278,13 @@ void AddDuplicateItem(NSMenuItem* top_level_item,
}
- (void)windowMainStatusChanged:(NSNotification*)notification {
// A Yosemite AppKit bug causes this notification to be sent during the
// -dealloc for a specific NSWindow. Any autoreleases sent to that window
// must be drained before the window finishes -dealloc. In this method, an
// autorelease is sent by the invocation of [NSApp windows].
// http://crbug.com/406944.
base::mac::ScopedNSAutoreleasePool pool;
id window = [notification object];
NSString* name = [notification name];
if ([name isEqualToString:NSWindowDidBecomeMainNotification]) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment