Clean up OS version checks for Apple platforms
Convert QSysInfo/QOperatingSystemVersion to __builtin_available where required or possible, or to QOperatingSystemVersion where __builtin_available cannot be used and is not needed (such as negated conditions, which are not supported by that construct). Change-Id: I83c0e7e777605b99ff4d24598bfcccf22126fdda Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
0f5c4ba7cb
commit
7fd3cc3980
@ -1 +1,6 @@
|
||||
SOURCES += futimens.cpp
|
||||
|
||||
# Block futimens() on Apple platforms unless it's available on ALL deployment
|
||||
# targets. This simplifies the logic at the call site dramatically, as it isn't
|
||||
# strictly needed compared to futimes().
|
||||
darwin: QMAKE_CXXFLAGS += -Werror=unguarded-availability
|
||||
|
@ -1232,11 +1232,7 @@ bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSy
|
||||
bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
|
||||
{
|
||||
#if QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(101200, 100000, 100000, 30000)
|
||||
const auto current = QOperatingSystemVersion::current();
|
||||
if (current >= QOperatingSystemVersion::MacOSSierra ||
|
||||
current >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 10) ||
|
||||
current >= QOperatingSystemVersion(QOperatingSystemVersion::TvOS, 10) ||
|
||||
current >= QOperatingSystemVersion(QOperatingSystemVersion::WatchOS, 3)) {
|
||||
if (__builtin_available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *)) {
|
||||
if (::clonefile(source.nativeFilePath().constData(),
|
||||
target.nativeFilePath().constData(), 0) == 0)
|
||||
return true;
|
||||
@ -1271,11 +1267,7 @@ bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSy
|
||||
}
|
||||
#endif
|
||||
#if defined(Q_OS_DARWIN) && defined(RENAME_EXCL)
|
||||
const auto current = QOperatingSystemVersion::current();
|
||||
if (current >= QOperatingSystemVersion::MacOSSierra ||
|
||||
current >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 10) ||
|
||||
current >= QOperatingSystemVersion(QOperatingSystemVersion::TvOS, 10) ||
|
||||
current >= QOperatingSystemVersion(QOperatingSystemVersion::WatchOS, 3)) {
|
||||
if (__builtin_available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *)) {
|
||||
if (renameatx_np(AT_FDCWD, srcPath, AT_FDCWD, tgtPath, RENAME_EXCL) == 0)
|
||||
return true;
|
||||
if (errno != ENOTSUP) {
|
||||
|
@ -284,7 +284,7 @@ QT_END_NAMESPACE
|
||||
inLaunch = false;
|
||||
|
||||
if (qEnvironmentVariableIsEmpty("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM")) {
|
||||
if (QSysInfo::macVersion() >= QSysInfo::MV_10_12) {
|
||||
if (__builtin_available(macOS 10.12, *)) {
|
||||
// Move the application window to front to avoid launching behind the terminal.
|
||||
// Ignoring other apps is necessary (we must ignore the terminal), but makes
|
||||
// Qt apps play slightly less nice with other apps when lanching from Finder
|
||||
|
@ -163,7 +163,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate);
|
||||
[mSavePanel setDelegate:self];
|
||||
|
||||
#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_11)
|
||||
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::OSXElCapitan)
|
||||
if (__builtin_available(macOS 10.11, *))
|
||||
mOpenPanel.accessoryViewDisclosed = YES;
|
||||
#endif
|
||||
|
||||
|
@ -363,7 +363,7 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList)
|
||||
// Move the application window to front to make it take focus, also when launching
|
||||
// from the terminal. On 10.12+ this call has been moved to applicationDidFinishLauching
|
||||
// to work around issues with loss of focus at startup.
|
||||
if (QSysInfo::macVersion() < QSysInfo::MV_10_12) {
|
||||
if (QOperatingSystemVersion::current() < QOperatingSystemVersion::MacOSSierra) {
|
||||
// Ignoring other apps is necessary (we must ignore the terminal), but makes
|
||||
// Qt apps play slightly less nice with other apps when lanching from Finder
|
||||
// (See the activateIgnoringOtherApps docs.)
|
||||
|
@ -232,7 +232,7 @@ static bool isMouseEvent(NSEvent *ev)
|
||||
NSApplication *application = [NSApplication sharedApplication];
|
||||
|
||||
#if QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12)
|
||||
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSSierra) {
|
||||
if (__builtin_available(macOS 10.12, *)) {
|
||||
// Unfortunately there's no NSWindowListOrderedBackToFront,
|
||||
// so we have to manually reverse the order using an array.
|
||||
NSMutableArray *windows = [[[NSMutableArray alloc] init] autorelease];
|
||||
|
@ -117,7 +117,7 @@ QIOSIntegration::QIOSIntegration()
|
||||
m_touchDevice = new QTouchDevice;
|
||||
m_touchDevice->setType(QTouchDevice::TouchScreen);
|
||||
QTouchDevice::Capabilities touchCapabilities = QTouchDevice::Position | QTouchDevice::NormalizedPosition;
|
||||
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 9)) {
|
||||
if (__builtin_available(iOS 9, *)) {
|
||||
if (mainScreen.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)
|
||||
touchCapabilities |= QTouchDevice::Pressure;
|
||||
}
|
||||
|
@ -238,7 +238,7 @@
|
||||
self.inputAccessoryView = [[[WrapperView alloc] initWithView:accessoryView] autorelease];
|
||||
|
||||
#ifndef Q_OS_TVOS
|
||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_9_0) {
|
||||
if (__builtin_available(iOS 9, *)) {
|
||||
if (platformData.value(kImePlatformDataHideShortcutsBar).toBool()) {
|
||||
// According to the docs, leadingBarButtonGroups/trailingBarButtonGroups should be set to nil to hide the shortcuts bar.
|
||||
// However, starting with iOS 10, the API has been surrounded with NS_ASSUME_NONNULL, which contradicts this and causes
|
||||
|
@ -48,7 +48,6 @@
|
||||
#include "qiosmenu.h"
|
||||
#endif
|
||||
|
||||
#include <QtCore/qoperatingsystemversion.h>
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
#include <QtGui/private/qwindow_p.h>
|
||||
#include <qpa/qwindowsysteminterface_p.h>
|
||||
@ -294,7 +293,7 @@
|
||||
QTouchDevice *touchDevice = QIOSIntegration::instance()->touchDevice();
|
||||
QTouchDevice::Capabilities touchCapabilities = touchDevice->capabilities();
|
||||
|
||||
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 9)) {
|
||||
if (__builtin_available(iOS 9, *)) {
|
||||
if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)
|
||||
touchCapabilities |= QTouchDevice::Pressure;
|
||||
else
|
||||
|
@ -1,6 +1,6 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qtimer
|
||||
QT = core testlib
|
||||
QT = core core-private testlib
|
||||
SOURCES = tst_qtimer.cpp
|
||||
|
||||
# Force C++17 if available
|
||||
|
@ -33,11 +33,11 @@
|
||||
# include <QtCore/QCoreApplication>
|
||||
#endif
|
||||
|
||||
#include <QtCore/private/qglobal_p.h>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#include <qtimer.h>
|
||||
#include <qthread.h>
|
||||
#include <qoperatingsystemversion.h>
|
||||
|
||||
#if defined Q_OS_UNIX
|
||||
#include <unistd.h>
|
||||
@ -500,7 +500,7 @@ void tst_QTimer::moveToThread()
|
||||
#if defined(Q_OS_WIN32)
|
||||
QSKIP("Does not work reliably on Windows :(");
|
||||
#elif defined(Q_OS_MACOS)
|
||||
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSSierra)
|
||||
if (__builtin_available(macOS 10.12, *))
|
||||
QSKIP("Does not work reliably on macOS 10.12 (QTBUG-59679)");
|
||||
#endif
|
||||
QTimer ti1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
CONFIG += testcase
|
||||
TARGET = tst_qguitimer
|
||||
QT = core gui testlib
|
||||
QT = core core-private gui testlib
|
||||
SOURCES += ../../../corelib/kernel/qtimer/tst_qtimer.cpp
|
||||
|
Loading…
x
Reference in New Issue
Block a user