diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-08-23 18:57:59 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-08-25 09:34:36 +0000 |
commit | 42588a84878c4d58ba5bf46636e31ba99a11227a (patch) | |
tree | e2bfe2acfe38e4d5724dcd6801cc8c70955e5b88 /src/corelib/kernel/qcore_mac_objc.mm | |
parent | 563c9eb4eefe758ed101ef246dbcbece8877d77c (diff) |
Improve detection and handling of unsupported Apple platforms
The application name wasn't always printed, so we try try a few
more possibilities before falling back to the process name.
We also run the check as early as possible, instead of relying
on a QCoreApplication.
We do not have to provide a dialog to the user, as macOS will do
this for us if the application is launched from Finder.
Change-Id: Ifbec86946d60294806364e08964852fd4b74ff56
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/corelib/kernel/qcore_mac_objc.mm')
-rw-r--r-- | src/corelib/kernel/qcore_mac_objc.mm | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index 2e303607df..4ca9c2e996 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -448,16 +448,23 @@ void qt_apple_check_os_version() version / 10000, version / 100 % 100, version % 100}; 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", - (reinterpret_cast<const NSString *>( - NSBundle.mainBundle.infoDictionary[@"CFBundleName"]).UTF8String), - os, - os, long(current.majorVersion), long(current.minorVersion), long(current.patchVersion), - os, long(required.majorVersion), long(required.minorVersion), long(required.patchVersion)); - abort(); + NSDictionary *plist = NSBundle.mainBundle.infoDictionary; + NSString *applicationName = plist[@"CFBundleDisplayName"]; + if (!applicationName) + applicationName = plist[@"CFBundleName"]; + if (!applicationName) + applicationName = NSProcessInfo.processInfo.processName; + + fprintf(stderr, "Sorry, \"%s\" can not be run on this version of %s. " + "Qt requires %s %ld.%ld.%ld or later, you have %s %ld.%ld.%ld.\n", + applicationName.UTF8String, os, + os, long(required.majorVersion), long(required.minorVersion), long(required.patchVersion), + os, long(current.majorVersion), long(current.minorVersion), long(current.patchVersion)); + + exit(1); } } +Q_CONSTRUCTOR_FUNCTION(qt_apple_check_os_version); // ------------------------------------------------------------------------- |