From 534899baa28940692f8ae639896b2009f688e981 Mon Sep 17 00:00:00 2001 From: Jeff Hostetler Date: Fri, 19 Aug 2016 23:03:47 +0200 Subject: [PATCH] Work around unwanted MacOpenFiles() calls in wxOSX applications Don't try to open any command line arguments as files by using the workaround from Colin Barrett (see https://bugzilla.mozilla.org/show_bug.cgi?id=366009). --- docs/changes.txt | 1 + src/osx/cocoa/utils.mm | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index abb9a61a6b..4c5f58fe8e 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -128,6 +128,7 @@ wxOSX: - Implement wxDataViewChoiceByIndexRenderer (wanup). - Fix unnecessary indentation in list-like wxDataViewCtrl (Andreas Falkenhahn). - Recognize macOS 10.12 Sierra in wxGetOsDescription() (Tobias Taschner). +- Don't try to open command line arguments as files (Jeff Hostetler). Unix: diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index 02c18c47f9..7636672002 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -421,6 +421,11 @@ bool wxApp::DoInitGui() } gNSLayoutManager = [[NSLayoutManager alloc] init]; + // This call makes it so that appplication:openFile: doesn't get bogus calls + // from Cocoa doing its own parsing of the argument string. And yes, we need + // to use a string with a boolean value in it. That's just how it works. + [[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"]; + return true; }