Remove codepaths and checks for unsupported Apple platforms

We no longer support macOS 10.11, iOS/tvOS 10, or watchOS 3.

Change-Id: Ide03d8fac06185ef4162ba75ee54a0adf6916905
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Tor Arne Vestbø 2018-08-24 15:41:42 +02:00
parent 29c0377f07
commit b02fe1bfe7
14 changed files with 98 additions and 216 deletions

View File

@ -24,5 +24,3 @@ load(default_pre)
!versionAtLeast(QMAKE_XCODE_VERSION, 4.3): \ !versionAtLeast(QMAKE_XCODE_VERSION, 4.3): \
error("This mkspec requires Xcode 4.3 or later") error("This mkspec requires Xcode 4.3 or later")
ios:shared:!versionAtLeast(QMAKE_IOS_DEPLOYMENT_TARGET, 8.0): \
QMAKE_IOS_DEPLOYMENT_TARGET = 8.0

View File

@ -1768,8 +1768,7 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
# elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) # elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
handledStderr |= android_default_message_handler(type, context, message); handledStderr |= android_default_message_handler(type, context, message);
# elif defined(QT_USE_APPLE_UNIFIED_LOGGING) # elif defined(QT_USE_APPLE_UNIFIED_LOGGING)
if (__builtin_available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *)) handledStderr |= AppleUnifiedLogger::messageHandler(type, context, message);
handledStderr |= AppleUnifiedLogger::messageHandler(type, context, message);
# elif defined Q_OS_WASM # elif defined Q_OS_WASM
handledStderr |= wasm_default_message_handler(type, context, message); handledStderr |= wasm_default_message_handler(type, context, message);
# endif # endif

View File

@ -76,9 +76,7 @@
#endif #endif
#if defined(Q_OS_DARWIN) #if defined(Q_OS_DARWIN)
# if QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(101200, 100000, 100000, 30000) # include <sys/clonefile.h>
# include <sys/clonefile.h>
# endif
# include <copyfile.h> # include <copyfile.h>
// We cannot include <Foundation/Foundation.h> (it's an Objective-C header), but // We cannot include <Foundation/Foundation.h> (it's an Objective-C header), but
// we need these declarations: // we need these declarations:
@ -1258,20 +1256,18 @@ bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSy
//static //static
bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
{ {
#if QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(101200, 100000, 100000, 30000) #if defined(Q_OS_DARWIN)
if (__builtin_available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *)) { if (::clonefile(source.nativeFilePath().constData(),
if (::clonefile(source.nativeFilePath().constData(), target.nativeFilePath().constData(), 0) == 0)
target.nativeFilePath().constData(), 0) == 0) return true;
return true; error = QSystemError(errno, QSystemError::StandardLibraryError);
error = QSystemError(errno, QSystemError::StandardLibraryError); return false;
return false;
}
#else #else
Q_UNUSED(source); Q_UNUSED(source);
Q_UNUSED(target); Q_UNUSED(target);
#endif
error = QSystemError(ENOSYS, QSystemError::StandardLibraryError); //Function not implemented error = QSystemError(ENOSYS, QSystemError::StandardLibraryError); //Function not implemented
return false; return false;
#endif
} }
//static //static
@ -1295,13 +1291,11 @@ bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSy
} }
#endif #endif
#if defined(Q_OS_DARWIN) && defined(RENAME_EXCL) #if defined(Q_OS_DARWIN) && defined(RENAME_EXCL)
if (__builtin_available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *)) { if (renameatx_np(AT_FDCWD, srcPath, AT_FDCWD, tgtPath, RENAME_EXCL) == 0)
if (renameatx_np(AT_FDCWD, srcPath, AT_FDCWD, tgtPath, RENAME_EXCL) == 0) return true;
return true; if (errno != ENOTSUP) {
if (errno != ENOTSUP) { error = QSystemError(errno, QSystemError::StandardLibraryError);
error = QSystemError(errno, QSystemError::StandardLibraryError); return false;
return false;
}
} }
#endif #endif

View File

@ -59,36 +59,6 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#if !defined(QT_BOOTSTRAPPED) && (QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12) || !defined(Q_OS_MACOS))
#define QT_USE_APPLE_ACTIVITIES
#if defined(OS_ACTIVITY_OBJECT_API)
#error The file <os/activity.h> has already been included
#endif
// We runtime-check all use of the activity APIs, so we can safely build
// with them included, even if the deployment target is macOS 10.11
#if QT_MACOS_DEPLOYMENT_TARGET_BELOW(__MAC_10_12)
#undef __MAC_OS_X_VERSION_MIN_REQUIRED
#define __MAC_OS_X_VERSION_MIN_REQUIRED __MAC_10_12
#define DID_OVERRIDE_DEPLOYMENT_TARGET
#endif
#include <os/activity.h>
#if !OS_ACTIVITY_OBJECT_API
#error "Expected activity API to be available"
#endif
#if defined(DID_OVERRIDE_DEPLOYMENT_TARGET)
#undef __MAC_OS_X_VERSION_MIN_REQUIRED
#define __MAC_OS_X_VERSION_MIN_REQUIRED __MAC_10_11
#undef DID_OVERRIDE_DEPLOYMENT_TARGET
#endif
#endif
// --------------------------------------------------------------------------
#if defined(QT_BOOTSTRAPPED) #if defined(QT_BOOTSTRAPPED)
#include <ApplicationServices/ApplicationServices.h> #include <ApplicationServices/ApplicationServices.h>
#else #else
@ -220,41 +190,31 @@ Q_CORE_EXPORT AppleApplication *qt_apple_sharedApplication();
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#if !defined(QT_BOOTSTRAPPED) && (QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12) || !defined(Q_OS_MACOS)) #if !defined(QT_BOOTSTRAPPED)
#define QT_USE_APPLE_UNIFIED_LOGGING #define QT_USE_APPLE_UNIFIED_LOGGING
QT_END_NAMESPACE QT_END_NAMESPACE
#include <os/log.h> #include <os/log.h>
// The compiler isn't smart enough to realize that we're calling these functions
// guarded by __builtin_available, so we need to also tag each function with the
// runtime requirements.
#include <os/availability.h>
#define OS_LOG_AVAILABILITY API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT AppleUnifiedLogger class Q_CORE_EXPORT AppleUnifiedLogger
{ {
public: public:
static bool messageHandler(QtMsgType msgType, const QMessageLogContext &context, const QString &message, static bool messageHandler(QtMsgType msgType, const QMessageLogContext &context, const QString &message,
const QString &subsystem = QString()) OS_LOG_AVAILABILITY; const QString &subsystem = QString());
private: private:
static os_log_type_t logTypeForMessageType(QtMsgType msgType) OS_LOG_AVAILABILITY; static os_log_type_t logTypeForMessageType(QtMsgType msgType);
static os_log_t cachedLog(const QString &subsystem, const QString &category) OS_LOG_AVAILABILITY; static os_log_t cachedLog(const QString &subsystem, const QString &category);
}; };
#undef OS_LOG_AVAILABILITY
#endif #endif
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#if defined(QT_USE_APPLE_ACTIVITIES) #if !defined(QT_BOOTSTRAPPED)
QT_END_NAMESPACE QT_END_NAMESPACE
#include <os/availability.h> #include <os/activity.h>
#define OS_ACTIVITY_AVAILABILITY API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
#define OS_ACTIVITY_AVAILABILITY_CHECK __builtin_available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *)
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
template <typename T> using QAppleOsType = QAppleRefCounted<T, void *, os_retain, os_release>; template <typename T> using QAppleOsType = QAppleRefCounted<T, void *, os_retain, os_release>;
@ -263,7 +223,7 @@ class Q_CORE_EXPORT QAppleLogActivity
{ {
public: public:
QAppleLogActivity() : activity(nullptr) {} QAppleLogActivity() : activity(nullptr) {}
QAppleLogActivity(os_activity_t activity) OS_ACTIVITY_AVAILABILITY : activity(activity) {} QAppleLogActivity(os_activity_t activity) : activity(activity) {}
~QAppleLogActivity() { if (activity) leave(); } ~QAppleLogActivity() { if (activity) leave(); }
QAppleLogActivity(const QAppleLogActivity &) = delete; QAppleLogActivity(const QAppleLogActivity &) = delete;
@ -284,21 +244,17 @@ public:
QAppleLogActivity&& enter() QAppleLogActivity&& enter()
{ {
if (activity) { if (activity)
if (OS_ACTIVITY_AVAILABILITY_CHECK) os_activity_scope_enter(static_cast<os_activity_t>(*this), &state);
os_activity_scope_enter(static_cast<os_activity_t>(*this), &state);
}
return std::move(*this); return std::move(*this);
} }
void leave() { void leave() {
if (activity) { if (activity)
if (OS_ACTIVITY_AVAILABILITY_CHECK) os_activity_scope_leave(&state);
os_activity_scope_leave(&state);
}
} }
operator os_activity_t() OS_ACTIVITY_AVAILABILITY operator os_activity_t()
{ {
return reinterpret_cast<os_activity_t>(static_cast<void *>(activity)); return reinterpret_cast<os_activity_t>(static_cast<void *>(activity));
} }
@ -312,9 +268,7 @@ private:
#define QT_APPLE_LOG_ACTIVITY_CREATE(condition, description, parent) []() { \ #define QT_APPLE_LOG_ACTIVITY_CREATE(condition, description, parent) []() { \
if (!(condition)) \ if (!(condition)) \
return QAppleLogActivity(); \ return QAppleLogActivity(); \
if (OS_ACTIVITY_AVAILABILITY_CHECK) \ return QAppleLogActivity(os_activity_create(description, parent, OS_ACTIVITY_FLAG_DEFAULT)); \
return QAppleLogActivity(os_activity_create(description, parent, OS_ACTIVITY_FLAG_DEFAULT)); \
return QAppleLogActivity(); \
}() }()
#define QT_VA_ARGS_CHOOSE(_1, _2, _3, _4, _5, _6, _7, _8, _9, N, ...) N #define QT_VA_ARGS_CHOOSE(_1, _2, _3, _4, _5, _6, _7, _8, _9, N, ...) N
@ -335,12 +289,7 @@ QT_MAC_WEAK_IMPORT(_os_activity_current);
#define QT_APPLE_SCOPED_LOG_ACTIVITY(...) QAppleLogActivity scopedLogActivity = QT_APPLE_LOG_ACTIVITY(__VA_ARGS__).enter(); #define QT_APPLE_SCOPED_LOG_ACTIVITY(...) QAppleLogActivity scopedLogActivity = QT_APPLE_LOG_ACTIVITY(__VA_ARGS__).enter();
#else #endif // !defined(QT_BOOTSTRAPPED)
// No-ops for macOS 10.11. We don't need to provide QT_APPLE_SCOPED_LOG_ACTIVITY,
// as all the call sites for that are in code that's only built on 10.12 and above.
#define QT_APPLE_LOG_ACTIVITY_WITH_PARENT(...)
#define QT_APPLE_LOG_ACTIVITY(...)
#endif // QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------

View File

@ -267,13 +267,11 @@ QT_USE_NAMESPACE
inLaunch = false; inLaunch = false;
if (qEnvironmentVariableIsEmpty("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM")) { if (qEnvironmentVariableIsEmpty("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM")) {
if (__builtin_available(macOS 10.12, *)) { // Move the application window to front to avoid launching behind the terminal.
// Move the application window to front to avoid launching behind the terminal. // Ignoring other apps is necessary (we must ignore the terminal), but makes
// 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
// Qt apps play slightly less nice with other apps when lanching from Finder // (See the activateIgnoringOtherApps docs.)
// (See the activateIgnoringOtherApps docs.) [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
} }
} }

View File

@ -67,11 +67,6 @@ QImage::Format QCocoaBackingStore::format() const
return QRasterBackingStore::format(); return QRasterBackingStore::format();
} }
#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12)
static const NSCompositingOperation NSCompositingOperationCopy = NSCompositeCopy;
static const NSCompositingOperation NSCompositingOperationSourceOver = NSCompositeSourceOver;
#endif
/*! /*!
Flushes the given \a region from the specified \a window onto the Flushes the given \a region from the specified \a window onto the
screen. screen.

View File

@ -262,29 +262,20 @@ static bool isMouseEvent(NSEvent *ev)
NSEnumerator<NSWindow*> *windowEnumerator = nullptr; NSEnumerator<NSWindow*> *windowEnumerator = nullptr;
NSApplication *application = [NSApplication sharedApplication]; NSApplication *application = [NSApplication sharedApplication];
#if QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12) // Unfortunately there's no NSWindowListOrderedBackToFront,
if (__builtin_available(macOS 10.12, *)) { // so we have to manually reverse the order using an array.
// Unfortunately there's no NSWindowListOrderedBackToFront, NSMutableArray<NSWindow *> *windows = [NSMutableArray<NSWindow *> new];
// so we have to manually reverse the order using an array. [application enumerateWindowsWithOptions:NSWindowListOrderedFrontToBack
NSMutableArray<NSWindow *> *windows = [NSMutableArray<NSWindow *> new]; usingBlock:^(NSWindow *window, BOOL *) {
[application enumerateWindowsWithOptions:NSWindowListOrderedFrontToBack // For some reason AppKit will give us nil-windows, skip those
usingBlock:^(NSWindow *window, BOOL *) { if (!window)
// For some reason AppKit will give us nil-windows, skip those return;
if (!window)
return;
[windows addObject:window]; [windows addObject:window];
} }
]; ];
windowEnumerator = windows.reverseObjectEnumerator; windowEnumerator = windows.reverseObjectEnumerator;
} else
#endif
{
// No way to get ordered list of windows, so fall back to unordered,
// list, which typically corresponds to window creation order.
windowEnumerator = application.windows.objectEnumerator;
}
for (NSWindow *window in windowEnumerator) { for (NSWindow *window in windowEnumerator) {
// We're meddling with normal and floating windows, so leave others alone // We're meddling with normal and floating windows, so leave others alone

View File

@ -115,10 +115,8 @@ void QIOSIntegration::initialize()
m_touchDevice = new QTouchDevice; m_touchDevice = new QTouchDevice;
m_touchDevice->setType(QTouchDevice::TouchScreen); m_touchDevice->setType(QTouchDevice::TouchScreen);
QTouchDevice::Capabilities touchCapabilities = QTouchDevice::Position | QTouchDevice::NormalizedPosition; QTouchDevice::Capabilities touchCapabilities = QTouchDevice::Position | QTouchDevice::NormalizedPosition;
if (__builtin_available(iOS 9, *)) { if (mainScreen.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)
if (mainScreen.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) touchCapabilities |= QTouchDevice::Pressure;
touchCapabilities |= QTouchDevice::Pressure;
}
m_touchDevice->setCapabilities(touchCapabilities); m_touchDevice->setCapabilities(touchCapabilities);
QWindowSystemInterface::registerTouchDevice(m_touchDevice); QWindowSystemInterface::registerTouchDevice(m_touchDevice);
#if QT_CONFIG(tabletevent) #if QT_CONFIG(tabletevent)

View File

@ -456,12 +456,7 @@ qreal QIOSScreen::devicePixelRatio() const
qreal QIOSScreen::refreshRate() const qreal QIOSScreen::refreshRate() const
{ {
#if QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, 100300, 110000, __WATCHOS_NA) return m_uiScreen.maximumFramesPerSecond;
if (__builtin_available(iOS 10.3, tvOS 11, *))
return m_uiScreen.maximumFramesPerSecond;
#endif
return 60.0;
} }
Qt::ScreenOrientation QIOSScreen::nativeOrientation() const Qt::ScreenOrientation QIOSScreen::nativeOrientation() const

View File

@ -244,17 +244,15 @@
self.inputAccessoryView = [[[WrapperView alloc] initWithView:accessoryView] autorelease]; self.inputAccessoryView = [[[WrapperView alloc] initWithView:accessoryView] autorelease];
#ifndef Q_OS_TVOS #ifndef Q_OS_TVOS
if (__builtin_available(iOS 9, *)) { if (platformData.value(kImePlatformDataHideShortcutsBar).toBool()) {
if (platformData.value(kImePlatformDataHideShortcutsBar).toBool()) { // According to the docs, leadingBarButtonGroups/trailingBarButtonGroups should be set to nil to hide the shortcuts bar.
// 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
// However, starting with iOS 10, the API has been surrounded with NS_ASSUME_NONNULL, which contradicts this and causes // compiler warnings. Still it is the way to go to really hide the space reserved for that.
// compiler warnings. Still it is the way to go to really hide the space reserved for that.
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonnull" #pragma clang diagnostic ignored "-Wnonnull"
self.inputAssistantItem.leadingBarButtonGroups = nil; self.inputAssistantItem.leadingBarButtonGroups = nil;
self.inputAssistantItem.trailingBarButtonGroups = nil; self.inputAssistantItem.trailingBarButtonGroups = nil;
#pragma clang diagnostic pop #pragma clang diagnostic pop
}
} }
#endif #endif

View File

@ -128,21 +128,17 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
self.layer.borderWidth = 1.0; self.layer.borderWidth = 1.0;
} }
#if QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, 110000, 110000, __WATCHOS_NA)
if (qEnvironmentVariableIsSet("QT_IOS_DEBUG_WINDOW_SAFE_AREAS")) { if (qEnvironmentVariableIsSet("QT_IOS_DEBUG_WINDOW_SAFE_AREAS")) {
if (__builtin_available(iOS 11, tvOS 11, *)) { UIView *safeAreaOverlay = [[UIView alloc] initWithFrame:CGRectZero];
UIView *safeAreaOverlay = [[UIView alloc] initWithFrame:CGRectZero]; [safeAreaOverlay setBackgroundColor:[UIColor colorWithRed:0.3 green:0.7 blue:0.9 alpha:0.3]];
[safeAreaOverlay setBackgroundColor:[UIColor colorWithRed:0.3 green:0.7 blue:0.9 alpha:0.3]]; [self addSubview:safeAreaOverlay];
[self addSubview:safeAreaOverlay];
safeAreaOverlay.translatesAutoresizingMaskIntoConstraints = NO; safeAreaOverlay.translatesAutoresizingMaskIntoConstraints = NO;
[safeAreaOverlay.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor].active = YES; [safeAreaOverlay.topAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.topAnchor].active = YES;
[safeAreaOverlay.leftAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.leftAnchor].active = YES; [safeAreaOverlay.leftAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.leftAnchor].active = YES;
[safeAreaOverlay.rightAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.rightAnchor].active = YES; [safeAreaOverlay.rightAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.rightAnchor].active = YES;
[safeAreaOverlay.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor].active = YES; [safeAreaOverlay.bottomAnchor constraintEqualToAnchor:self.safeAreaLayoutGuide.bottomAnchor].active = YES;
}
} }
#endif
} }
return self; return self;
@ -355,12 +351,10 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
QTouchDevice *touchDevice = QIOSIntegration::instance()->touchDevice(); QTouchDevice *touchDevice = QIOSIntegration::instance()->touchDevice();
QTouchDevice::Capabilities touchCapabilities = touchDevice->capabilities(); QTouchDevice::Capabilities touchCapabilities = touchDevice->capabilities();
if (__builtin_available(iOS 9, *)) { if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)
if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) touchCapabilities |= QTouchDevice::Pressure;
touchCapabilities |= QTouchDevice::Pressure; else
else touchCapabilities &= ~QTouchDevice::Pressure;
touchCapabilities &= ~QTouchDevice::Pressure;
}
touchDevice->setCapabilities(touchCapabilities); touchDevice->setCapabilities(touchCapabilities);
} }
@ -668,18 +662,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
- (UIEdgeInsets)qt_safeAreaInsets - (UIEdgeInsets)qt_safeAreaInsets
{ {
#if QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, 110000, 110000, __WATCHOS_NA) return self.safeAreaInsets;
if (__builtin_available(iOS 11, tvOS 11, *))
return self.safeAreaInsets;
#endif
// Fallback for iOS < 11
UIEdgeInsets safeAreaInsets = UIEdgeInsetsZero;
CGPoint topInset = [self convertPoint:CGPointMake(0, self.viewController.topLayoutGuide.length) fromView:nil];
CGPoint bottomInset = [self convertPoint:CGPointMake(0, self.viewController.bottomLayoutGuide.length) fromView:nil];
safeAreaInsets.top = topInset.y;
safeAreaInsets.bottom = bottomInset.y;
return safeAreaInsets;
} }
@end @end

View File

@ -1735,17 +1735,10 @@ NSView *QMacStylePrivate::cocoaControl(CocoaControl widget) const
} }
Q_UNREACHABLE(); Q_UNREACHABLE();
} (); } ();
#if QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12)
const auto styleMask = NSWindowStyleMaskTitled const auto styleMask = NSWindowStyleMaskTitled
| NSWindowStyleMaskClosable | NSWindowStyleMaskClosable
| NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskMiniaturizable
| NSWindowStyleMaskResizable; | NSWindowStyleMaskResizable;
#else
const auto styleMask = NSTitledWindowMask
| NSClosableWindowMask
| NSMiniaturizableWindowMask
| NSResizableWindowMask;
#endif
bv = [NSWindow standardWindowButton:button forStyleMask:styleMask]; bv = [NSWindow standardWindowButton:button forStyleMask:styleMask];
[bv retain]; [bv retain];
break; break;

View File

@ -52,10 +52,7 @@ bool QAppleTestLogger::debugLoggingEnabled()
// Debug-level messages are only captured in memory when debug logging is // Debug-level messages are only captured in memory when debug logging is
// enabled through a configuration change, which can happen automatically // enabled through a configuration change, which can happen automatically
// when running inside Xcode, or with the Console application open. // when running inside Xcode, or with the Console application open.
if (__builtin_available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *)) return os_log_type_enabled(OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG);
return os_log_type_enabled(OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG);
return false;
} }
QAppleTestLogger::QAppleTestLogger(QAbstractTestLogger *logger) QAppleTestLogger::QAppleTestLogger(QAbstractTestLogger *logger)
@ -71,15 +68,13 @@ void QAppleTestLogger::enterTestFunction(const char *function)
// Re-create activity each time // Re-create activity each time
testFunctionActivity = QT_APPLE_LOG_ACTIVITY("Running test function").enter(); testFunctionActivity = QT_APPLE_LOG_ACTIVITY("Running test function").enter();
if (__builtin_available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *)) { QTestCharBuffer testIdentifier;
QTestCharBuffer testIdentifier; QTestPrivate::generateTestIdentifier(&testIdentifier);
QTestPrivate::generateTestIdentifier(&testIdentifier); QString identifier = QString::fromLatin1(testIdentifier.data());
QString identifier = QString::fromLatin1(testIdentifier.data()); QMessageLogContext context(nullptr, 0, nullptr, "qt.test.enter");
QMessageLogContext context(nullptr, 0, nullptr, "qt.test.enter"); QString message = identifier;
QString message = identifier; if (AppleUnifiedLogger::messageHandler(QtDebugMsg, context, message, identifier))
if (AppleUnifiedLogger::messageHandler(QtDebugMsg, context, message, identifier)) return; // AUL already printed to stderr
return; // AUL already printed to stderr
}
m_logger->enterTestFunction(function); m_logger->enterTestFunction(function);
} }
@ -113,41 +108,38 @@ static IncidentClassification incidentTypeToClassification(QAbstractTestLogger::
void QAppleTestLogger::addIncident(IncidentTypes type, const char *description, void QAppleTestLogger::addIncident(IncidentTypes type, const char *description,
const char *file, int line) const char *file, int line)
{ {
if (__builtin_available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *)) {
IncidentClassification incidentClassification = incidentTypeToClassification(type);
QTestCharBuffer category; IncidentClassification incidentClassification = incidentTypeToClassification(type);
QTest::qt_asprintf(&category, "qt.test.%s", incidentClassification.second);
QMessageLogContext context(file, line, /* function = */ nullptr, category.data());
QTestCharBuffer subsystemBuffer; QTestCharBuffer category;
// It would be nice to have the data tag as part of the subsystem too, but that QTest::qt_asprintf(&category, "qt.test.%s", incidentClassification.second);
// will for some tests results in hundreds of thousands of log objects being QMessageLogContext context(file, line, /* function = */ nullptr, category.data());
// created, so we limit the subsystem to test functions, which we can hope
// are reasonably limited.
generateTestIdentifier(&subsystemBuffer, TestObject | TestFunction);
QString subsystem = QString::fromLatin1(subsystemBuffer.data());
// We still want the full identifier as part of the message though QTestCharBuffer subsystemBuffer;
QTestCharBuffer testIdentifier; // It would be nice to have the data tag as part of the subsystem too, but that
generateTestIdentifier(&testIdentifier); // will for some tests results in hundreds of thousands of log objects being
QString message = QString::fromLatin1(testIdentifier.data()); // created, so we limit the subsystem to test functions, which we can hope
if (qstrlen(description)) // are reasonably limited.
message += QLatin1Char('\n') % QString::fromLatin1(description); generateTestIdentifier(&subsystemBuffer, TestObject | TestFunction);
QString subsystem = QString::fromLatin1(subsystemBuffer.data());
if (AppleUnifiedLogger::messageHandler(incidentClassification.first, context, message, subsystem)) // We still want the full identifier as part of the message though
return; // AUL already printed to stderr QTestCharBuffer testIdentifier;
} generateTestIdentifier(&testIdentifier);
QString message = QString::fromLatin1(testIdentifier.data());
if (qstrlen(description))
message += QLatin1Char('\n') % QString::fromLatin1(description);
if (AppleUnifiedLogger::messageHandler(incidentClassification.first, context, message, subsystem))
return; // AUL already printed to stderr
m_logger->addIncident(type, description, file, line); m_logger->addIncident(type, description, file, line);
} }
void QAppleTestLogger::addMessage(QtMsgType type, const QMessageLogContext &context, const QString &message) void QAppleTestLogger::addMessage(QtMsgType type, const QMessageLogContext &context, const QString &message)
{ {
if (__builtin_available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *)) { if (AppleUnifiedLogger::messageHandler(type, context, message))
if (AppleUnifiedLogger::messageHandler(type, context, message)) return; // AUL already printed to stderr
return; // AUL already printed to stderr
}
m_logger->addMessage(type, context, message); m_logger->addMessage(type, context, message);
} }

View File

@ -456,8 +456,7 @@ void tst_QTimer::moveToThread()
#if defined(Q_OS_WIN32) #if defined(Q_OS_WIN32)
QSKIP("Does not work reliably on Windows :("); QSKIP("Does not work reliably on Windows :(");
#elif defined(Q_OS_MACOS) #elif defined(Q_OS_MACOS)
if (__builtin_available(macOS 10.12, *)) QSKIP("Does not work reliably on macOS 10.12+ (QTBUG-59679)");
QSKIP("Does not work reliably on macOS 10.12 (QTBUG-59679)");
#endif #endif
QTimer ti1; QTimer ti1;
QTimer ti2; QTimer ti2;