summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2020-03-16 18:41:27 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2020-03-16 20:43:50 +0100
commitc2f167b41284cee3570434deba85f26f14ff241f (patch)
treeb0f52f86a8df266547d7ec7afa22d0c0d68d3532 /src/corelib/kernel
parent9f9049b486a47aef0c7e2e3852b20aa4ffdce748 (diff)
parentff922e7b87de147797fbd759167878aec7625f0c (diff)
Merge "Merge remote-tracking branch 'origin/5.15' into dev"
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/kernel.pri10
-rw-r--r--src/corelib/kernel/qcore_mac.cpp163
-rw-r--r--src/corelib/kernel/qcore_mac.mm (renamed from src/corelib/kernel/qcore_mac_objc.mm)119
-rw-r--r--src/corelib/kernel/qdeadlinetimer.cpp10
4 files changed, 128 insertions, 174 deletions
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 1b4f6d4923..76609894ba 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -120,14 +120,12 @@ mac {
SOURCES += \
kernel/qcfsocketnotifier.cpp \
kernel/qcoreapplication_mac.cpp \
- kernel/qcore_mac.cpp \
- kernel/qcore_foundation.mm
- !nacl: SOURCES += kernel/qelapsedtimer_mac.cpp
-
- OBJECTIVE_SOURCES += \
- kernel/qcore_mac_objc.mm \
+ kernel/qcore_foundation.mm \
+ kernel/qcore_mac.mm \
kernel/qeventdispatcher_cf.mm
+ !nacl: SOURCES += kernel/qelapsedtimer_mac.cpp
+
LIBS_PRIVATE += -framework Foundation
osx: LIBS_PRIVATE += -framework CoreServices -framework AppKit -framework Security
diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp
deleted file mode 100644
index e59835be48..0000000000
--- a/src/corelib/kernel/qcore_mac.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qcore_mac_p.h>
-#include <new>
-
-#include "qhash.h"
-#include "qpair.h"
-#include "qmutex.h"
-#include "qvarlengtharray.h"
-#include "private/qlocking_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QCFString::operator QString() const
-{
- if (string.isEmpty() && value)
- const_cast<QCFString*>(this)->string = QString::fromCFString(value);
- return string;
-}
-
-QCFString::operator CFStringRef() const
-{
- if (!value)
- const_cast<QCFString*>(this)->value = string.toCFString();
- return value;
-}
-
-// --------------------------------------------------------------------------
-
-#if defined(QT_USE_APPLE_UNIFIED_LOGGING)
-
-bool AppleUnifiedLogger::willMirrorToStderr()
-{
- // When running under Xcode or LLDB, one or more of these variables will
- // be set, which triggers libsystem_trace.dyld to log messages to stderr
- // as well, via_os_log_impl_mirror_to_stderr. Un-setting these variables
- // is not an option, as that would silence normal NSLog or os_log calls,
- // so instead we skip our own stderr output. See rdar://36919139.
- static bool willMirror = qEnvironmentVariableIsSet("OS_ACTIVITY_DT_MODE")
- || qEnvironmentVariableIsSet("ACTIVITY_LOG_STDERR")
- || qEnvironmentVariableIsSet("CFLOG_FORCE_STDERR");
- return willMirror;
-}
-
-QT_MAC_WEAK_IMPORT(_os_log_default);
-bool AppleUnifiedLogger::messageHandler(QtMsgType msgType, const QMessageLogContext &context,
- const QString &message, const QString &optionalSubsystem)
-{
- QString subsystem = optionalSubsystem;
- if (subsystem.isNull()) {
- static QString bundleIdentifier = []() {
- if (CFBundleRef bundle = CFBundleGetMainBundle()) {
- if (CFStringRef identifier = CFBundleGetIdentifier(bundle))
- return QString::fromCFString(identifier);
- }
- return QString();
- }();
- subsystem = bundleIdentifier;
- }
-
- const bool isDefault = !context.category || !strcmp(context.category, "default");
- os_log_t log = isDefault ? OS_LOG_DEFAULT :
- cachedLog(subsystem, QString::fromLatin1(context.category));
- os_log_type_t logType = logTypeForMessageType(msgType);
-
- if (!os_log_type_enabled(log, logType))
- return false;
-
- // Logging best practices says we should not include symbolication
- // information or source file line numbers in messages, as the system
- // will automatically captures this information. In our case, what
- // the system captures is the call to os_log_with_type below, which
- // isn't really useful, but we still don't want to include the context's
- // info, as that would clutter the logging output. See rdar://35958308.
-
- // The format must be a string constant, so we can't pass on the
- // message. This means we won't be able to take advantage of the
- // unified logging's custom format specifiers such as %{BOOL}d.
- // We use the 'public' format specifier to prevent the logging
- // system from redacting our log message.
- os_log_with_type(log, logType, "%{public}s", qPrintable(message));
-
- return willMirrorToStderr();
-}
-
-os_log_type_t AppleUnifiedLogger::logTypeForMessageType(QtMsgType msgType)
-{
- switch (msgType) {
- case QtDebugMsg: return OS_LOG_TYPE_DEBUG;
- case QtInfoMsg: return OS_LOG_TYPE_INFO;
- case QtWarningMsg: return OS_LOG_TYPE_DEFAULT;
- case QtCriticalMsg: return OS_LOG_TYPE_ERROR;
- case QtFatalMsg: return OS_LOG_TYPE_FAULT;
- }
-
- return OS_LOG_TYPE_DEFAULT;
-}
-
-os_log_t AppleUnifiedLogger::cachedLog(const QString &subsystem, const QString &category)
-{
- static QBasicMutex mutex;
- const auto locker = qt_scoped_lock(mutex);
-
- static QHash<QPair<QString, QString>, os_log_t> logs;
- const auto cacheKey = qMakePair(subsystem, category);
- os_log_t log = logs.value(cacheKey);
-
- if (!log) {
- log = os_log_create(subsystem.toLatin1().constData(),
- category.toLatin1().constData());
- logs.insert(cacheKey, log);
-
- // Technically we should release the os_log_t resource when done
- // with it, but since we don't know when a category is disabled
- // we keep all cached os_log_t instances until shutdown, where
- // the OS will clean them up for us.
- }
-
- return log;
-}
-
-#endif // QT_USE_APPLE_UNIFIED_LOGGING
-
-// --------------------------------------------------------------------------
-
-QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac.mm
index a042361686..0d334e7300 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac.mm
@@ -48,6 +48,7 @@
#include <UIKit/UIKit.h>
#endif
+#include <new>
#include <execinfo.h>
#include <dlfcn.h>
#include <cxxabi.h>
@@ -55,8 +56,126 @@
#include <qdebug.h>
+#include "qhash.h"
+#include "qpair.h"
+#include "qmutex.h"
+#include "qvarlengtharray.h"
+#include "private/qlocking_p.h"
+
QT_BEGIN_NAMESPACE
+// --------------------------------------------------------------------------
+
+QCFString::operator QString() const
+{
+ if (string.isEmpty() && value)
+ const_cast<QCFString*>(this)->string = QString::fromCFString(value);
+ return string;
+}
+
+QCFString::operator CFStringRef() const
+{
+ if (!value)
+ const_cast<QCFString*>(this)->value = string.toCFString();
+ return value;
+}
+
+// --------------------------------------------------------------------------
+
+#if defined(QT_USE_APPLE_UNIFIED_LOGGING)
+
+bool AppleUnifiedLogger::willMirrorToStderr()
+{
+ // When running under Xcode or LLDB, one or more of these variables will
+ // be set, which triggers libsystem_trace.dyld to log messages to stderr
+ // as well, via_os_log_impl_mirror_to_stderr. Un-setting these variables
+ // is not an option, as that would silence normal NSLog or os_log calls,
+ // so instead we skip our own stderr output. See rdar://36919139.
+ static bool willMirror = qEnvironmentVariableIsSet("OS_ACTIVITY_DT_MODE")
+ || qEnvironmentVariableIsSet("ACTIVITY_LOG_STDERR")
+ || qEnvironmentVariableIsSet("CFLOG_FORCE_STDERR");
+ return willMirror;
+}
+
+QT_MAC_WEAK_IMPORT(_os_log_default);
+bool AppleUnifiedLogger::messageHandler(QtMsgType msgType, const QMessageLogContext &context,
+ const QString &message, const QString &optionalSubsystem)
+{
+ QString subsystem = optionalSubsystem;
+ if (subsystem.isNull()) {
+ static QString bundleIdentifier = []() {
+ if (CFBundleRef bundle = CFBundleGetMainBundle()) {
+ if (CFStringRef identifier = CFBundleGetIdentifier(bundle))
+ return QString::fromCFString(identifier);
+ }
+ return QString();
+ }();
+ subsystem = bundleIdentifier;
+ }
+
+ const bool isDefault = !context.category || !strcmp(context.category, "default");
+ os_log_t log = isDefault ? OS_LOG_DEFAULT :
+ cachedLog(subsystem, QString::fromLatin1(context.category));
+ os_log_type_t logType = logTypeForMessageType(msgType);
+
+ if (!os_log_type_enabled(log, logType))
+ return false;
+
+ // Logging best practices says we should not include symbolication
+ // information or source file line numbers in messages, as the system
+ // will automatically captures this information. In our case, what
+ // the system captures is the call to os_log_with_type below, which
+ // isn't really useful, but we still don't want to include the context's
+ // info, as that would clutter the logging output. See rdar://35958308.
+
+ // The format must be a string constant, so we can't pass on the
+ // message. This means we won't be able to take advantage of the
+ // unified logging's custom format specifiers such as %{BOOL}d.
+ // We use the 'public' format specifier to prevent the logging
+ // system from redacting our log message.
+ os_log_with_type(log, logType, "%{public}s", qPrintable(message));
+
+ return willMirrorToStderr();
+}
+
+os_log_type_t AppleUnifiedLogger::logTypeForMessageType(QtMsgType msgType)
+{
+ switch (msgType) {
+ case QtDebugMsg: return OS_LOG_TYPE_DEBUG;
+ case QtInfoMsg: return OS_LOG_TYPE_INFO;
+ case QtWarningMsg: return OS_LOG_TYPE_DEFAULT;
+ case QtCriticalMsg: return OS_LOG_TYPE_ERROR;
+ case QtFatalMsg: return OS_LOG_TYPE_FAULT;
+ }
+
+ return OS_LOG_TYPE_DEFAULT;
+}
+
+os_log_t AppleUnifiedLogger::cachedLog(const QString &subsystem, const QString &category)
+{
+ static QBasicMutex mutex;
+ const auto locker = qt_scoped_lock(mutex);
+
+ static QHash<QPair<QString, QString>, os_log_t> logs;
+ const auto cacheKey = qMakePair(subsystem, category);
+ os_log_t log = logs.value(cacheKey);
+
+ if (!log) {
+ log = os_log_create(subsystem.toLatin1().constData(),
+ category.toLatin1().constData());
+ logs.insert(cacheKey, log);
+
+ // Technically we should release the os_log_t resource when done
+ // with it, but since we don't know when a category is disabled
+ // we keep all cached os_log_t instances until shutdown, where
+ // the OS will clean them up for us.
+ }
+
+ return log;
+}
+
+#endif // QT_USE_APPLE_UNIFIED_LOGGING
+
// -------------------------------------------------------------------------
QDebug operator<<(QDebug dbg, const NSObject *nsObject)
diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp
index 06b56bb09b..520153b2e5 100644
--- a/src/corelib/kernel/qdeadlinetimer.cpp
+++ b/src/corelib/kernel/qdeadlinetimer.cpp
@@ -438,8 +438,8 @@ inline bool TimeReference::toNanoseconds(qint64 *result) const
For such objects, remainingTime() will return -1, deadline() will return the
maximum value, and isForever() will return true.
- The timer type \a timerType may be ignored, since the timer is already
- expired.
+ The timer type \a timerType may be ignored, since the timer will never
+ expire.
\sa ForeverConstant, hasExpired(), isForever(), remainingTime(), timerType()
*/
@@ -449,9 +449,9 @@ inline bool TimeReference::toNanoseconds(qint64 *result) const
from the moment of the creation of this object, if msecs is positive. If \a
msecs is zero, this QDeadlineTimer will be marked as expired, causing
remainingTime() to return zero and deadline() to return an indeterminate
- time point in the past. If \a msecs is -1, the timer will be set it to
- never expire, causing remainingTime() to return -1 and deadline() to return
- the maximum value.
+ time point in the past. If \a msecs is -1, the timer will be set to never
+ expire, causing remainingTime() to return -1 and deadline() to return the
+ maximum value.
The QDeadlineTimer object will be constructed with the specified timer \a type.