diff options
-rw-r--r-- | src/corelib/kernel/qcore_mac_objc.mm | 30 | ||||
-rw-r--r-- | src/corelib/kernel/qcore_mac_p.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 3 |
3 files changed, 35 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index 02e1232c64..ce4f01625e 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -280,6 +280,36 @@ Qt::Key qt_mac_cocoaKey2QtKey(QChar keyCode) #endif // Q_OS_OSX +void qt_apple_check_os_version() +{ +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + const char *os = "iOS"; + const int version = __IPHONE_OS_VERSION_MIN_REQUIRED; +#elif defined(__TV_OS_VERSION_MIN_REQUIRED) + const char *os = "tvOS"; + const int version = __TV_OS_VERSION_MIN_REQUIRED; +#elif defined(__WATCH_OS_VERSION_MIN_REQUIRED) + const char *os = "watchOS"; + const int version = __WATCH_OS_VERSION_MIN_REQUIRED; +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + const char *os = "macOS"; + const int version = __MAC_OS_X_VERSION_MIN_REQUIRED; +#endif + const NSOperatingSystemVersion required = version >= 100000 + ? (NSOperatingSystemVersion){version / 10000, version / 100 % 100, version % 100} + : (NSOperatingSystemVersion){version / 100, version / 10 % 10, version % 10}; + const NSOperatingSystemVersion current = NSProcessInfo.processInfo.operatingSystemVersion; + if (![NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:required]) { + fprintf(stderr, "You can't use this version of %s with this version of %s. " + "You have %s %ld.%ld.%ld. Qt requires %s %ld.%ld.%ld or later.\n", + ((NSString *)NSBundle.mainBundle.infoDictionary[@"CFBundleName"]).UTF8String, + os, + os, current.majorVersion, current.minorVersion, current.patchVersion, + os, required.majorVersion, required.minorVersion, required.patchVersion); + abort(); + } +} + // ------------------------------------------------------------------------- QT_END_NAMESPACE diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index 12e9518979..5be8df1a48 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -152,6 +152,8 @@ Q_CORE_EXPORT QChar qt_mac_qtKey2CocoaKey(Qt::Key key); Q_CORE_EXPORT Qt::Key qt_mac_cocoaKey2QtKey(QChar keyCode); #endif +Q_CORE_EXPORT void qt_apple_check_os_version(); + QT_END_NAMESPACE #endif // QCORE_MAC_P_H diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 6141a73966..1f736d7bf6 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -437,6 +437,9 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint , q_ptr(0) #endif { +#if defined(Q_OS_DARWIN) + qt_apple_check_os_version(); +#endif app_compile_version = flags & 0xffffff; static const char *const empty = ""; if (argc == 0 || argv == 0) { |