From 0a22df3a9d25bfce1e38e3dbabdde036a2cf5425 Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Mon, 29 Jun 2020 00:37:50 -0400 Subject: [PATCH] Analytics: Remove deprecated usage of Gestalt to get macOS version --- Source/Core/Core/Analytics.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/Source/Core/Core/Analytics.cpp b/Source/Core/Core/Analytics.cpp index af289b4ff5..aba45139e8 100644 --- a/Source/Core/Core/Analytics.cpp +++ b/Source/Core/Core/Analytics.cpp @@ -12,7 +12,7 @@ #if defined(_WIN32) #include #elif defined(__APPLE__) -#include +#include #elif defined(ANDROID) #include #include "Common/AndroidAnalytics.h" @@ -268,20 +268,26 @@ void DolphinAnalytics::MakeBaseBuilder() #elif defined(__APPLE__) builder.AddData("os-type", "osx"); - SInt32 osxmajor, osxminor, osxbugfix; -// Gestalt is deprecated, but the replacement (NSProcessInfo -// operatingSystemVersion) is only available on OS X 10.10, so we need to use -// it anyway. Change this someday when Dolphin depends on 10.10+. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - Gestalt(gestaltSystemVersionMajor, &osxmajor); - Gestalt(gestaltSystemVersionMinor, &osxminor); - Gestalt(gestaltSystemVersionBugFix, &osxbugfix); -#pragma GCC diagnostic pop + // id processInfo = [NSProcessInfo processInfo] + id processInfo = reinterpret_cast(objc_msgSend)( + objc_getClass("NSProcessInfo"), sel_getUid("processInfo")); + if (processInfo) + { + struct OSVersion // NSOperatingSystemVersion + { + s64 major_version; // NSInteger majorVersion + s64 minor_version; // NSInteger minorVersion + s64 patch_version; // NSInteger patchVersion + }; - builder.AddData("osx-ver-major", osxmajor); - builder.AddData("osx-ver-minor", osxminor); - builder.AddData("osx-ver-bugfix", osxbugfix); + // NSOperatingSystemVersion version = [processInfo operatingSystemVersion] + OSVersion version = reinterpret_cast(objc_msgSend_stret)( + processInfo, sel_getUid("operatingSystemVersion")); + + builder.AddData("osx-ver-major", version.major_version); + builder.AddData("osx-ver-minor", version.minor_version); + builder.AddData("osx-ver-bugfix", version.patch_version); + } #elif defined(__linux__) builder.AddData("os-type", "linux"); #elif defined(__FreeBSD__)