Analytics: Remove deprecated usage of Gestalt to get macOS version
This commit is contained in:
parent
2e8d1dd1db
commit
0a22df3a9d
|
@ -12,7 +12,7 @@
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#include <CoreServices/CoreServices.h>
|
#include <objc/message.h>
|
||||||
#elif defined(ANDROID)
|
#elif defined(ANDROID)
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "Common/AndroidAnalytics.h"
|
#include "Common/AndroidAnalytics.h"
|
||||||
|
@ -268,20 +268,26 @@ void DolphinAnalytics::MakeBaseBuilder()
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
builder.AddData("os-type", "osx");
|
builder.AddData("os-type", "osx");
|
||||||
|
|
||||||
SInt32 osxmajor, osxminor, osxbugfix;
|
// id processInfo = [NSProcessInfo processInfo]
|
||||||
// Gestalt is deprecated, but the replacement (NSProcessInfo
|
id processInfo = reinterpret_cast<id (*)(Class, SEL)>(objc_msgSend)(
|
||||||
// operatingSystemVersion) is only available on OS X 10.10, so we need to use
|
objc_getClass("NSProcessInfo"), sel_getUid("processInfo"));
|
||||||
// it anyway. Change this someday when Dolphin depends on 10.10+.
|
if (processInfo)
|
||||||
#pragma GCC diagnostic push
|
{
|
||||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
struct OSVersion // NSOperatingSystemVersion
|
||||||
Gestalt(gestaltSystemVersionMajor, &osxmajor);
|
{
|
||||||
Gestalt(gestaltSystemVersionMinor, &osxminor);
|
s64 major_version; // NSInteger majorVersion
|
||||||
Gestalt(gestaltSystemVersionBugFix, &osxbugfix);
|
s64 minor_version; // NSInteger minorVersion
|
||||||
#pragma GCC diagnostic pop
|
s64 patch_version; // NSInteger patchVersion
|
||||||
|
};
|
||||||
|
|
||||||
builder.AddData("osx-ver-major", osxmajor);
|
// NSOperatingSystemVersion version = [processInfo operatingSystemVersion]
|
||||||
builder.AddData("osx-ver-minor", osxminor);
|
OSVersion version = reinterpret_cast<OSVersion (*)(id, SEL)>(objc_msgSend_stret)(
|
||||||
builder.AddData("osx-ver-bugfix", osxbugfix);
|
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__)
|
#elif defined(__linux__)
|
||||||
builder.AddData("os-type", "linux");
|
builder.AddData("os-type", "linux");
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
|
|
Loading…
Reference in New Issue