summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNyx0uf <benjgodard@me.com>2013-09-16 19:35:01 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-09-16 21:51:08 +0200
commit95a2151d199e7e77979fa54ff500d02bf8d8b377 (patch)
tree3031f7b4785b6e4cf1b8e48d9ba32bc155e2f0a9
parent44b66962795e3bbf58363c3e512480333d09d43c (diff)
downloadmpv-95a2151d199e7e77979fa54ff500d02bf8d8b377.tar.bz2
mpv-95a2151d199e7e77979fa54ff500d02bf8d8b377.tar.xz
macosx_application: remove deprecation warning on OS X 10.9
GetCurrentProcess() is deprecated on 10.9. Make a universal solution by checking OS version number. get_system_version() function is the recommended Apple way of getting the OS version, since Gestalt is also deprecated (and does pretty much the same thing anyway) Updating HIDRemote.m to use a similar function would allow to get rid of the 2 other warnings.
-rw-r--r--osdep/macosx_application.m44
1 files changed, 29 insertions, 15 deletions
diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m
index b03e1731f5..3f12454c9b 100644
--- a/osdep/macosx_application.m
+++ b/osdep/macosx_application.m
@@ -413,25 +413,39 @@ static void macosx_redirect_output_to_logfile(const char *filename)
[pool release];
}
-static bool psn_matches_current_process(char *psn_arg_to_check)
-{
- ProcessSerialNumber psn;
- GetCurrentProcess(&psn);
-
- NSString *in_psn = [NSString stringWithUTF8String:psn_arg_to_check];
- NSString *real_psn = [NSString stringWithFormat:@"-psn_%u_%u",
- psn.highLongOfPSN, psn.lowLongOfPSN];
-
- return [real_psn isEqualToString:in_psn];
+static void get_system_version(int* major, int* minor, int* bugfix)
+{
+ static dispatch_once_t once_token;
+ static int s_major = 0;
+ static int s_minor = 0;
+ static int s_bugfix = 0;
+ dispatch_once(&once_token, ^{
+ NSString *version_plist =
+ @"/System/Library/CoreServices/SystemVersion.plist";
+ NSString *version_string =
+ [NSDictionary dictionaryWithContentsOfFile:version_plist]
+ [@"ProductVersion"];
+ NSArray* versions = [version_string componentsSeparatedByString:@"."];
+ int count = [versions count];
+ if (count >= 1)
+ s_major = [versions[0] intValue];
+ if (count >= 2)
+ s_minor = [versions[1] intValue];
+ if (count >= 3)
+ s_bugfix = [versions[2] intValue];
+ });
+ *major = s_major;
+ *minor = s_minor;
+ *bugfix = s_bugfix;
}
static bool bundle_started_from_finder(int argc, char **argv)
{
- bool bundle_detected = [[NSBundle mainBundle] bundleIdentifier];
- bool pre_mavericks_args = argc==2 && psn_matches_current_process(argv[1]);
- bool post_mavericks_args = argc==1;
-
- return bundle_detected && (pre_mavericks_args || post_mavericks_args);
+ 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;
}
void macosx_finder_args_preinit(int *argc, char ***argv)