macosx_application: fix regression causing crash

95a2151d1 introduced a crash on systems lower than 10.9 when opening files
with a single argument.
This commit is contained in:
Stefano Pigozzi 2013-09-19 22:03:49 +02:00
parent 00d8e85373
commit 061b6ab3aa
1 changed files with 11 additions and 2 deletions

View File

@ -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)