50 | | v.m_major = osv.majorVersion; |
51 | | v.m_minor = osv.minorVersion; |
52 | | v.m_micro = osv.patchVersion; |
| 55 | v.m_major = -1; |
| 56 | v.m_minor = -1; |
| 57 | v.m_micro = -1; |
| 58 | #if QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_8_0) || defined(Q_OS_TVOS) || defined(Q_OS_WATCHOS) |
| 59 | if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) { |
| 60 | NSOperatingSystemVersion osv = NSProcessInfo.processInfo.operatingSystemVersion; |
| 61 | v.m_major = osv.majorVersion; |
| 62 | v.m_minor = osv.minorVersion; |
| 63 | v.m_micro = osv.patchVersion; |
| 64 | return v; |
| 65 | } |
| 66 | #endif |
| 67 | // Use temporary variables so we can return 0.0.0 (unknown version) |
| 68 | // in case of an error partway through determining the OS version |
| 69 | qint32 major = 0, minor = 0, patch = 0; |
| 70 | #if QT_MACOS_IOS_DEPLOYMENT_TARGET_BELOW(__MAC_10_10, __IPHONE_8_0) |
| 71 | #if defined(Q_OS_IOS) |
| 72 | @autoreleasepool { |
| 73 | NSArray *parts = [UIDevice.currentDevice.systemVersion componentsSeparatedByString:@"."]; |
| 74 | major = parts.count > 0 ? [[parts objectAtIndex:0] intValue] : 0; |
| 75 | minor = parts.count > 1 ? [[parts objectAtIndex:1] intValue] : 0; |
| 76 | patch = parts.count > 2 ? [[parts objectAtIndex:2] intValue] : 0; |
| 77 | } |
| 78 | #elif defined(Q_OS_MACOS) |
| 79 | static GestaltFunction pGestalt = 0; |
| 80 | if (!pGestalt) { |
| 81 | CFBundleRef b = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CoreServices")); |
| 82 | pGestalt = reinterpret_cast<GestaltFunction>(CFBundleGetFunctionPointerForName(b, |
| 83 | CFSTR("Gestalt"))); |
| 84 | } |
| 85 | if (!pGestalt) |
| 86 | return v; |
| 87 | if (pGestalt('sys1', &major) != 0) |
| 88 | return v; |
| 89 | if (pGestalt('sys2', &minor) != 0) |
| 90 | return v; |
| 91 | if (pGestalt('sys3', &patch) != 0) |
| 92 | return v; |
| 93 | #endif |
| 94 | #endif |
| 95 | v.m_major = major; |
| 96 | v.m_minor = minor; |
| 97 | v.m_micro = patch; |