diff options
author | Jake Petroules <jake.petroules@petroules.com> | 2014-06-13 18:59:30 -0400 |
---|---|---|
committer | Jake Petroules <jake.petroules@petroules.com> | 2014-09-12 22:01:58 +0200 |
commit | 4e8720d413ceca288408ae34bc726f768ca467c6 (patch) | |
tree | a3386a6e1d2df84434d02d07d14f4a8bd2037251 /src/corelib/global | |
parent | fac71528cce279282d66b0a96ddd8570d567955f (diff) |
Use new, supported APIs in OS X 10.10 and iOS 8.0 to get the OS version.
Gestalt is deprecated so we can't use it long term. At the same time,
the new API is cross platform, so we'll no longer have to parse strings
in -[UIDevice systemVersion] either.
Change-Id: Ic81797174c1a3d50b47b9b209205a6a506cc75ef
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qglobal.cpp | 34 | ||||
-rw-r--r-- | src/corelib/global/qsysinfo.h | 1 |
2 files changed, 9 insertions, 26 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index f526387eb4..c15cee1e3b 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1854,16 +1854,14 @@ Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr) { QSysInfo::MacVersion QSysInfo::macVersion() { + const QAppleOperatingSystemVersion version = qt_apple_os_version(); // qtcore_mac_objc.mm #if defined(Q_OS_OSX) - SInt32 gestalt_version; - if (Gestalt(gestaltSystemVersionMinor, &gestalt_version) == noErr) { - // add 2 because OS X 10.0 is 0x02 in the enum - return QSysInfo::MacVersion(gestalt_version + 2); - } + return QSysInfo::MacVersion(Q_MV_OSX(version.major, version.minor)); #elif defined(Q_OS_IOS) - return qt_ios_version(); // qtcore_mac_objc.mm -#endif + return QSysInfo::MacVersion(Q_MV_IOS(version.major, version.minor)); +#else return QSysInfo::MV_Unknown; +#endif } const QSysInfo::MacVersion QSysInfo::MacintoshVersion = QSysInfo::macVersion(); @@ -2502,25 +2500,9 @@ QString QSysInfo::productType() */ QString QSysInfo::productVersion() { -#if defined(Q_OS_IOS) - int major = (int(MacintoshVersion) >> 4) & 0xf; - int minor = int(MacintoshVersion) & 0xf; - if (Q_LIKELY(major < 10 && minor < 10)) { - char buf[4] = { char(major + '0'), '.', char(minor + '0'), '\0' }; - return QString::fromLatin1(buf, 3); - } - return QString::number(major) + QLatin1Char('.') + QString::number(minor); -#elif defined(Q_OS_OSX) - int minor = int(MacintoshVersion) - 2; // we're not running on Mac OS 9 - Q_ASSERT(minor < 100); - char buf[] = "10.0\0"; - if (Q_LIKELY(minor < 10)) { - buf[3] += minor; - } else { - buf[3] += minor / 10; - buf[4] = '0' + minor % 10; - } - return QString::fromLatin1(buf); +#if defined(Q_OS_MAC) + const QAppleOperatingSystemVersion version = qt_apple_os_version(); + return QString::number(version.major) + QLatin1Char('.') + QString::number(version.minor); #elif defined(Q_OS_WIN) const char *version = winVer_helper(); if (version) diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h index 3a443938f9..d4b9072e93 100644 --- a/src/corelib/global/qsysinfo.h +++ b/src/corelib/global/qsysinfo.h @@ -120,6 +120,7 @@ public: #endif #ifdef Q_OS_MAC +# define Q_MV_OSX(major, minor) (major == 10 ? minor + 2 : (major == 9 ? 1 : 0)) # define Q_MV_IOS(major, minor) (QSysInfo::MV_IOS | major << 4 | minor) enum MacVersion { MV_Unknown = 0x0000, |