From 061b6ab3aaf08e3f1ff65b19efca940ed43e7db2 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 19 Sep 2013 22:03:49 +0200 Subject: macosx_application: fix regression causing crash 95a2151d1 introduced a crash on systems lower than 10.9 when opening files with a single argument. --- osdep/macosx_application.m | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m index 3f12454c9b..7e6ab963eb 100644 --- a/osdep/macosx_application.m +++ b/osdep/macosx_application.m @@ -439,13 +439,22 @@ static void get_system_version(int* major, int* minor, int* bugfix) *bugfix = s_bugfix; } +static bool is_psn_argument(char *psn_arg_to_check) +{ + NSString *psn_arg = [NSString stringWithUTF8String:psn_arg_to_check]; + return [psn_arg hasPrefix:@"-psn_"]; +} + static bool bundle_started_from_finder(int argc, char **argv) { bool bundle_detected = [[NSBundle mainBundle] bundleIdentifier]; int major, minor, bugfix; get_system_version(&major, &minor, &bugfix); - bool finder_args = ((major == 10) && (minor >= 9)) ? argc==1 : argc==2; - return bundle_detected && finder_args; + if ((major == 10) && (minor >= 9)) { + return bundle_detected && argc==1; + } else { + return bundle_detected && argc==2 && is_psn_argument(argv[1]); + } } void macosx_finder_args_preinit(int *argc, char ***argv) -- cgit v1.2.3