summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.cpp6
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.h10
-rw-r--r--src/corelib/kernel/qcore_mac.cpp95
-rw-r--r--src/corelib/kernel/qcore_mac_p.h31
-rw-r--r--src/corelib/kernel/qcore_unix.cpp2
-rw-r--r--src/corelib/kernel/qcore_unix_p.h2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp37
-rw-r--r--src/corelib/kernel/qcoreapplication.h10
-rw-r--r--src/corelib/kernel/qdeadlinetimer.cpp16
-rw-r--r--src/corelib/kernel/qdeadlinetimer.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_cf.mm87
-rw-r--r--src/corelib/kernel/qeventdispatcher_cf_p.h20
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib_p.h24
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix_p.h26
-rw-r--r--src/corelib/kernel/qeventloop.cpp14
-rw-r--r--src/corelib/kernel/qeventloop.h4
-rw-r--r--src/corelib/kernel/qfunctions_vxworks.h3
-rw-r--r--src/corelib/kernel/qjni.cpp2
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp14
-rw-r--r--src/corelib/kernel/qjnionload.cpp2
-rw-r--r--src/corelib/kernel/qmetaobject.cpp48
-rw-r--r--src/corelib/kernel/qmetaobject.h38
-rw-r--r--src/corelib/kernel/qmetatype.cpp9
-rw-r--r--src/corelib/kernel/qmetatype.h111
-rw-r--r--src/corelib/kernel/qobject.cpp49
-rw-r--r--src/corelib/kernel/qobject.h69
-rw-r--r--src/corelib/kernel/qobject_impl.h4
-rw-r--r--src/corelib/kernel/qobject_p.h16
-rw-r--r--src/corelib/kernel/qobjectdefs.h41
-rw-r--r--src/corelib/kernel/qobjectdefs_impl.h9
-rw-r--r--src/corelib/kernel/qpointer.cpp44
-rw-r--r--src/corelib/kernel/qsharedmemory.cpp8
-rw-r--r--src/corelib/kernel/qsharedmemory.h4
-rw-r--r--src/corelib/kernel/qsocketnotifier.cpp4
-rw-r--r--src/corelib/kernel/qsocketnotifier.h4
-rw-r--r--src/corelib/kernel/qsystemerror_p.h52
-rw-r--r--src/corelib/kernel/qtimer.cpp16
-rw-r--r--src/corelib/kernel/qtimer.h6
-rw-r--r--src/corelib/kernel/qtranslator.cpp2
-rw-r--r--src/corelib/kernel/qtranslator.h4
-rw-r--r--src/corelib/kernel/qvariant.cpp72
-rw-r--r--src/corelib/kernel/qvariant.h37
-rw-r--r--src/corelib/kernel/qvariant_p.h6
-rw-r--r--src/corelib/kernel/qwineventnotifier.h4
44 files changed, 605 insertions, 459 deletions
diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp
index d1e436c371..304a7bda08 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.cpp
+++ b/src/corelib/kernel/qabstracteventdispatcher.cpp
@@ -479,12 +479,12 @@ bool QAbstractEventDispatcher::filterNativeEvent(const QByteArray &eventType, vo
the processing of the event should continue.
*/
-/*! \fn bool QAbstractEventDispatcher::registerEventNotifier(QWinEventNotifier *notifier);
+/*! \fn bool QAbstractEventDispatcher::registerEventNotifier(QWinEventNotifier *notifier)
This pure virtual method exists on windows only and has to be reimplemented by a Windows specific
event dispatcher implementation. \a notifier is the QWinEventNotifier instance to be registered.
- The method should return true if the registration of \a notifier was sucessful, otherwise false.
+ The method should return true if the registration of \a notifier was successful, otherwise false.
QWinEventNotifier calls this method in it's constructor and there should never be a need to call this
method directly.
@@ -492,7 +492,7 @@ bool QAbstractEventDispatcher::filterNativeEvent(const QByteArray &eventType, vo
\sa QWinEventNotifier, unregisterEventNotifier()
*/
-/*! \fn bool QAbstractEventDispatcher::unregisterEventNotifier(QWinEventNotifier *notifier);
+/*! \fn bool QAbstractEventDispatcher::unregisterEventNotifier(QWinEventNotifier *notifier)
This pure virtual method exists on windows only and has to be reimplemented by a Windows specific
event dispatcher implementation. \a notifier is the QWinEventNotifier instance to be unregistered.
diff --git a/src/corelib/kernel/qabstracteventdispatcher.h b/src/corelib/kernel/qabstracteventdispatcher.h
index 3a530cf1de..4775d3d47a 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.h
+++ b/src/corelib/kernel/qabstracteventdispatcher.h
@@ -49,7 +49,7 @@ class QAbstractNativeEventFilter;
class QAbstractEventDispatcherPrivate;
class QSocketNotifier;
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
class QWinEventNotifier;
#endif
@@ -70,10 +70,10 @@ public:
{ }
};
- explicit QAbstractEventDispatcher(QObject *parent = Q_NULLPTR);
+ explicit QAbstractEventDispatcher(QObject *parent = nullptr);
~QAbstractEventDispatcher();
- static QAbstractEventDispatcher *instance(QThread *thread = Q_NULLPTR);
+ static QAbstractEventDispatcher *instance(QThread *thread = nullptr);
virtual bool processEvents(QEventLoop::ProcessEventsFlags flags) = 0;
virtual bool hasPendingEvents() = 0; // ### Qt6: remove, mark final or make protected
@@ -95,7 +95,7 @@ public:
virtual int remainingTime(int timerId) = 0;
-#if defined(Q_OS_WIN) || defined(Q_QDOC)
+#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
virtual bool registerEventNotifier(QWinEventNotifier *notifier) = 0;
virtual void unregisterEventNotifier(QWinEventNotifier *notifier) = 0;
#endif
@@ -112,7 +112,7 @@ public:
bool filterNativeEvent(const QByteArray &eventType, void *message, long *result);
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED bool filterEvent(void *message)
- { return filterNativeEvent("", message, Q_NULLPTR); }
+ { return filterNativeEvent("", message, nullptr); }
#endif
Q_SIGNALS:
diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp
index bfb3b2ff07..b5df0db232 100644
--- a/src/corelib/kernel/qcore_mac.cpp
+++ b/src/corelib/kernel/qcore_mac.cpp
@@ -39,6 +39,9 @@
#include <private/qcore_mac_p.h>
#include <new>
+
+#include "qhash.h"
+#include "qpair.h"
#include "qvarlengtharray.h"
QT_BEGIN_NAMESPACE
@@ -57,4 +60,96 @@ QCFString::operator CFStringRef() const
return value;
}
+// --------------------------------------------------------------------------
+
+#if defined(QT_USE_APPLE_UNIFIED_LOGGING)
+
+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));
+
+ // 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 mirroredToStderr = qEnvironmentVariableIsSet("OS_ACTIVITY_DT_MODE")
+ || qEnvironmentVariableIsSet("ACTIVITY_LOG_STDERR")
+ || qEnvironmentVariableIsSet("CFLOG_FORCE_STDERR");
+ return mirroredToStderr;
+}
+
+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;
+ QMutexLocker locker(&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_p.h b/src/corelib/kernel/qcore_mac_p.h
index 13143a08bb..9c6cef68b2 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -159,6 +159,37 @@ QDebug operator<<(QDebug debug, const QMacAutoReleasePool *pool);
Q_CORE_EXPORT void qt_apple_check_os_version();
+// --------------------------------------------------------------------------
+
+#if !defined(QT_BOOTSTRAPPED) && (QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12) || !defined(Q_OS_MACOS))
+#define QT_USE_APPLE_UNIFIED_LOGGING
+
+QT_END_NAMESPACE
+#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
+
+class Q_CORE_EXPORT AppleUnifiedLogger
+{
+public:
+ static bool messageHandler(QtMsgType msgType, const QMessageLogContext &context, const QString &message,
+ const QString &subsystem = QString()) OS_LOG_AVAILABILITY;
+private:
+ static os_log_type_t logTypeForMessageType(QtMsgType msgType) OS_LOG_AVAILABILITY;
+ static os_log_t cachedLog(const QString &subsystem, const QString &category) OS_LOG_AVAILABILITY;
+};
+
+#undef OS_LOG_AVAILABILITY
+
+#endif
+
+// --------------------------------------------------------------------------
+
QT_END_NAMESPACE
#endif // QCORE_MAC_P_H
diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp
index 3b0da136ca..eb98cbef8f 100644
--- a/src/corelib/kernel/qcore_unix.cpp
+++ b/src/corelib/kernel/qcore_unix.cpp
@@ -130,7 +130,7 @@ int qt_safe_poll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout
if (!timeout_ts) {
// no timeout -> block forever
int ret;
- EINTR_LOOP(ret, qt_ppoll(fds, nfds, Q_NULLPTR));
+ EINTR_LOOP(ret, qt_ppoll(fds, nfds, nullptr));
return ret;
}
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index f78d2b9f24..e538a7e22b 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -362,7 +362,7 @@ Q_CORE_EXPORT int qt_safe_poll(struct pollfd *fds, nfds_t nfds, const struct tim
static inline int qt_poll_msecs(struct pollfd *fds, nfds_t nfds, int timeout)
{
- timespec ts, *pts = Q_NULLPTR;
+ timespec ts, *pts = nullptr;
if (timeout >= 0) {
ts.tv_sec = timeout / 1000;
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 3814894630..ef431baca6 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -116,6 +116,12 @@
# include <taskLib.h>
#endif
+#ifdef QT_BOOTSTRAPPED
+#include <private/qtrace_p.h>
+#else
+#include <qtcore_tracepoints_p.h>
+#endif
+
#include <algorithm>
QT_BEGIN_NAMESPACE
@@ -449,7 +455,7 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint
, argv(aargv)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
, origArgc(0)
- , origArgv(Q_NULLPTR)
+ , origArgv(nullptr)
#endif
, application_type(QCoreApplicationPrivate::Tty)
#ifndef QT_NO_QOBJECT
@@ -781,9 +787,17 @@ QCoreApplication::QCoreApplication(int &argc, char **argv
#endif
}
+/*!
+ \enum QCoreApplication::anonymous
+ \internal
+
+ \value ApplicationFlags QT_VERSION
+*/
void QCoreApplicationPrivate::init()
{
+ Q_TRACE(qcoreapplicationprivate_init_entry);
+
#if defined(Q_OS_MACOS)
QMacAutoReleasePool pool;
#endif
@@ -842,8 +856,9 @@ void QCoreApplicationPrivate::init()
#ifndef QT_NO_QOBJECT
// use the event dispatcher created by the app programmer (if any)
- if (!eventDispatcher)
- eventDispatcher = threadData->eventDispatcher.load();
+ Q_ASSERT(!eventDispatcher);
+ eventDispatcher = threadData->eventDispatcher.load();
+
// otherwise we create one
if (!eventDispatcher)
createEventDispatcher();
@@ -875,6 +890,8 @@ void QCoreApplicationPrivate::init()
#ifndef QT_NO_QOBJECT
is_app_running = true; // No longer starting up.
#endif
+
+ Q_TRACE(qcoreapplicationprivate_init_exit);
}
/*!
@@ -1372,6 +1389,13 @@ void QCoreApplicationPrivate::execCleanup()
By convention, a \a returnCode of 0 means success, and any non-zero
value indicates an error.
+ It's good practice to always connect signals to this slot using a
+ \l{Qt::}{QueuedConnection}. If a signal connected (non-queued) to this slot
+ is emitted before control enters the main event loop (such as before
+ "int main" calls \l{QCoreApplication::}{exec()}), the slot has no effect
+ and the application never exits. Using a queued connection ensures that the
+ slot will not be invoked until after control enters the main event loop.
+
Note that unlike the C library function of the same name, this
function \e does return to the caller -- it is event processing that
stops.
@@ -1915,6 +1939,13 @@ void QCoreApplicationPrivate::maybeQuit()
to quit(), and you also often connect e.g. QAbstractButton::clicked() or
signals in QAction, QMenu, or QMenuBar to it.
+ It's good practice to always connect signals to this slot using a
+ \l{Qt::}{QueuedConnection}. If a signal connected (non-queued) to this slot
+ is emitted before control enters the main event loop (such as before
+ "int main" calls \l{QCoreApplication::}{exec()}), the slot has no effect
+ and the application never exits. Using a queued connection ensures that the
+ slot will not be invoked until after control enters the main event loop.
+
Example:
\snippet code/src_corelib_kernel_qcoreapplication.cpp 1
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index 6555733c4e..a886c9d1d2 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -123,7 +123,7 @@ public:
static bool sendEvent(QObject *receiver, QEvent *event);
static void postEvent(QObject *receiver, QEvent *event, int priority = Qt::NormalEventPriority);
- static void sendPostedEvents(QObject *receiver = Q_NULLPTR, int event_type = 0);
+ static void sendPostedEvents(QObject *receiver = nullptr, int event_type = 0);
static void removePostedEvents(QObject *receiver, int eventType = 0);
#if QT_DEPRECATED_SINCE(5, 3)
QT_DEPRECATED static bool hasPendingEvents();
@@ -155,7 +155,7 @@ public:
static QString translate(const char * context,
const char * key,
- const char * disambiguation = Q_NULLPTR,
+ const char * disambiguation = nullptr,
int n = -1);
#if QT_DEPRECATED_SINCE(5, 0)
enum Encoding { UnicodeUTF8, Latin1, DefaultCodec = UnicodeUTF8, CodecForTr = UnicodeUTF8 };
@@ -187,7 +187,7 @@ Q_SIGNALS:
void applicationVersionChanged();
protected:
- bool event(QEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *) override;
virtual bool compressEvent(QEvent *, QObject *receiver, QPostEventList *);
#endif // QT_NO_QOBJECT
@@ -241,13 +241,13 @@ inline bool QCoreApplication::sendSpontaneousEvent(QObject *receiver, QEvent *ev
# define QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context)
#else
# define QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) \
- QT_DEPRECATED static inline QString trUtf8(const char *sourceText, const char *disambiguation = Q_NULLPTR, int n = -1) \
+ QT_DEPRECATED static inline QString trUtf8(const char *sourceText, const char *disambiguation = nullptr, int n = -1) \
{ return QCoreApplication::translate(#context, sourceText, disambiguation, n); }
#endif
#define Q_DECLARE_TR_FUNCTIONS(context) \
public: \
- static inline QString tr(const char *sourceText, const char *disambiguation = Q_NULLPTR, int n = -1) \
+ static inline QString tr(const char *sourceText, const char *disambiguation = nullptr, int n = -1) \
{ return QCoreApplication::translate(#context, sourceText, disambiguation, n); } \
QT_DECLARE_DEPRECATED_TR_FUNCTIONS(context) \
private:
diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp
index ae4ffdcefc..d8a670310b 100644
--- a/src/corelib/kernel/qdeadlinetimer.cpp
+++ b/src/corelib/kernel/qdeadlinetimer.cpp
@@ -181,9 +181,9 @@ Q_DECL_CONST_FUNCTION static inline QPair<qint64, qint64> toSecsAndNSecs(qint64
*/
/*!
- \fn QDeadlineTimer::QDeadlineTimer(ForeverConstant forever, Qt::TimerType timerType)
+ \fn QDeadlineTimer::QDeadlineTimer(ForeverConstant, Qt::TimerType timerType)
- QDeadlineTimer objects created with parameter \a forever never expire.
+ QDeadlineTimer objects created with ForeverConstant never expire.
For such objects, remainingTime() will return -1, deadline() will return the
maximum value, and isForever() will return true.
@@ -220,7 +220,7 @@ QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) Q_DECL_NOTHROW
}
/*!
- \fn QDeadlineTimer::QDeadlineTimer(std::chrono::time_point<Clock, Duration> deadline, Qt::TimerType type)
+ \fn template <class Clock, class Duration> QDeadlineTimer::QDeadlineTimer(std::chrono::time_point<Clock, Duration> deadline, Qt::TimerType type)
Constructs a QDeadlineTimer object with a deadline at \a deadline time
point, converting from the clock source \c{Clock} to Qt's internal clock
@@ -236,7 +236,7 @@ QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) Q_DECL_NOTHROW
*/
/*!
- \fn QDeadlineTimer::QDeadlineTimer(std::chrono::duration<Rep, Period> remaining, Qt::TimerType type)
+ \fn template <class Rep, class Period> QDeadlineTimer::QDeadlineTimer(std::chrono::duration<Rep, Period> remaining, Qt::TimerType type)
Constructs a QDeadlineTimer object with a remaining time of \a remaining.
If \a remaining is zero or negative, this QDeadlineTimer object will be
@@ -263,7 +263,7 @@ QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) Q_DECL_NOTHROW
*/
/*!
- \fn void QDeadlineTimer::setDeadline(std::chrono::time_point<Clock, Duration> deadline, Qt::TimerType type)
+ \fn template <class Clock, class Duration> void QDeadlineTimer::setDeadline(std::chrono::time_point<Clock, Duration> deadline, Qt::TimerType type)
Sets this QDeadlineTimer to the deadline marked by \a deadline time
point, converting from the clock source \c{Clock} to Qt's internal clock
@@ -329,7 +329,7 @@ void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs, Qt::Time
/*!
\overload
- \fn void QDeadlineTimer::setRemainingTime(std::chrono::duration<Rep, Period> remaining, Qt::TimerType type)
+ \fn template <class Rep, class Period> void QDeadlineTimer::setRemainingTime(std::chrono::duration<Rep, Period> remaining, Qt::TimerType type)
Sets the remaining time for this QDeadlineTimer object to \a remaining. If
\a remaining is zero or negative, this QDeadlineTimer object will be mark
@@ -756,13 +756,13 @@ QDeadlineTimer QDeadlineTimer::addNSecs(QDeadlineTimer dt, qint64 nsecs) Q_DECL_
*/
/*!
- \fn QDeadlineTimer & QDeadlineTimer::operator=(std::chrono::time_point<Clock, Duration> deadline_)
+ \fn template <class Clock, class Duration> QDeadlineTimer & QDeadlineTimer::operator=(std::chrono::time_point<Clock, Duration> deadline_)
Assigns \a deadline_ to this deadline timer.
*/
/*!
- \fn QDeadlineTimer & QDeadlineTimer::operator=(std::chrono::duration<Rep, Period> remaining)
+ \fn template <class Rep, class Period> QDeadlineTimer & QDeadlineTimer::operator=(std::chrono::duration<Rep, Period> remaining)
Sets this deadline timer to the \a remaining time.
*/
diff --git a/src/corelib/kernel/qdeadlinetimer.h b/src/corelib/kernel/qdeadlinetimer.h
index ddab0191ad..6c10e1025e 100644
--- a/src/corelib/kernel/qdeadlinetimer.h
+++ b/src/corelib/kernel/qdeadlinetimer.h
@@ -120,7 +120,7 @@ public:
QDeadlineTimer &operator-=(qint64 msecs)
{ *this = *this + (-msecs); return *this; }
-#if QT_HAS_INCLUDE(<chrono>) || defined(Q_QDOC)
+#if QT_HAS_INCLUDE(<chrono>) || defined(Q_CLANG_QDOC)
template <class Clock, class Duration>
QDeadlineTimer(std::chrono::time_point<Clock, Duration> deadline_,
Qt::TimerType type_ = Qt::CoarseTimer) : t2(0)
diff --git a/src/corelib/kernel/qeventdispatcher_cf.mm b/src/corelib/kernel/qeventdispatcher_cf.mm
index 608dea5426..8499b3fd57 100644
--- a/src/corelib/kernel/qeventdispatcher_cf.mm
+++ b/src/corelib/kernel/qeventdispatcher_cf.mm
@@ -112,14 +112,15 @@ static CFStringRef runLoopMode(NSDictionary *dictionary)
if (CFStringRef mode = runLoopMode(notification.userInfo))
m_runLoopModes.push(mode);
else
- qWarning("Encountered run loop push notification without run loop mode!");
+ qCWarning(lcEventDispatcher) << "Encountered run loop push notification without run loop mode!";
} else if (CFStringHasSuffix((CFStringRef)notification.name, CFSTR("RunLoopModePopNotification"))) {
CFStringRef mode = runLoopMode(notification.userInfo);
if (CFStringCompare(mode, [self currentMode], 0) == kCFCompareEqualTo)
m_runLoopModes.pop();
else
- qWarning("Tried to pop run loop mode '%s' that was never pushed!", qPrintable(QString::fromCFString(mode)));
+ qCWarning(lcEventDispatcher) << "Tried to pop run loop mode"
+ << qPrintable(QString::fromCFString(mode)) << "that was never pushed!";
Q_ASSERT(m_runLoopModes.size() >= 1);
}
@@ -134,6 +135,9 @@ static CFStringRef runLoopMode(NSDictionary *dictionary)
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher");
+Q_LOGGING_CATEGORY(lcEventDispatcherTimers, "qt.eventdispatcher.timers");
+
class RunLoopDebugger : public QObject
{
Q_OBJECT
@@ -177,10 +181,6 @@ QDebug operator<<(QDebug s, timespec tv)
return s;
}
-#if DEBUG_EVENT_DISPATCHER
-uint g_eventDispatcherIndentationLevel = 0;
-#endif
-
static const CFTimeInterval kCFTimeIntervalMinimum = 0;
static const CFTimeInterval kCFTimeIntervalDistantFuture = std::numeric_limits<CFTimeInterval>::max();
@@ -190,13 +190,7 @@ QEventDispatcherCoreFoundation::QEventDispatcherCoreFoundation(QObject *parent)
: QAbstractEventDispatcher(parent)
, m_processEvents(QEventLoop::EventLoopExec)
, m_postedEventsRunLoopSource(this, &QEventDispatcherCoreFoundation::processPostedEvents)
- , m_runLoopActivityObserver(this, &QEventDispatcherCoreFoundation::handleRunLoopActivity,
-#if DEBUG_EVENT_DISPATCHER
- kCFRunLoopAllActivities
-#else
- kCFRunLoopBeforeWaiting | kCFRunLoopAfterWaiting
-#endif
- )
+ , m_runLoopActivityObserver(this, &QEventDispatcherCoreFoundation::handleRunLoopActivity, kCFRunLoopAllActivities)
, m_runLoopModeTracker([[RunLoopModeTracker alloc] init])
, m_runLoopTimer(0)
, m_blockedRunLoopTimer(0)
@@ -247,14 +241,14 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
bool eventsProcessed = false;
if (flags & (QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers))
- qWarning() << "processEvents() flags" << flags << "not supported on iOS";
+ qCWarning(lcEventDispatcher) << "processEvents() flags" << flags << "not supported on iOS";
- qEventDispatcherDebug() << "Entering with " << flags; qIndent();
+ qCDebug(lcEventDispatcher) << "Processing events with flags" << flags;
if (m_blockedRunLoopTimer) {
Q_ASSERT(m_blockedRunLoopTimer == m_runLoopTimer);
- qEventDispatcherDebug() << "Recursing from blocked timer " << m_blockedRunLoopTimer;
+ qCDebug(lcEventDispatcher) << "Recursing from blocked timer" << m_blockedRunLoopTimer;
m_runLoopTimer = 0; // Unset current timer to force creation of new timer
updateTimers();
}
@@ -266,7 +260,7 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
m_postedEventsRunLoopSource.signal();
m_processEvents.deferredWakeUp = false;
- qEventDispatcherDebug() << "Processed deferred wake-up";
+ qCDebug(lcEventDispatcher) << "Processed deferred wake-up";
}
// The documentation states that this signal is emitted after the event
@@ -287,12 +281,12 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
CFTimeInterval duration = (m_processEvents.flags & QEventLoop::WaitForMoreEvents) ?
kCFTimeIntervalDistantFuture : kCFTimeIntervalMinimum;
- qEventDispatcherDebug() << "Calling CFRunLoopRunInMode = " << qPrintable(QString::fromCFString(mode))
- << " for " << duration << " ms, processing single source = " << returnAfterSingleSourceHandled; qIndent();
+ qCDebug(lcEventDispatcher) << "Calling CFRunLoopRunInMode =" << qPrintable(QString::fromCFString(mode))
+ << "for" << duration << "ms, processing single source =" << returnAfterSingleSourceHandled;
SInt32 result = CFRunLoopRunInMode(mode, duration, returnAfterSingleSourceHandled);
- qUnIndent(); qEventDispatcherDebug() << "result = " << qPrintableResult(result);
+ qCDebug(lcEventDispatcher) << "result =" << qPrintableResult(result);
eventsProcessed |= (result == kCFRunLoopRunHandledSource
|| m_processEvents.processedPostedEvents
@@ -316,15 +310,15 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
// immediately, since it has already been exited.
if (!currentEventLoop()->isRunning()) {
- qEventDispatcherDebug() << "Top level event loop was exited";
+ qCDebug(lcEventDispatcher) << "Top level event loop was exited";
break;
} else {
- qEventDispatcherDebug() << "Top level event loop still running, making another pass";
+ qCDebug(lcEventDispatcher) << "Top level event loop still running, making another pass";
}
} else {
// We were called manually, through processEvents(), and should stop processing
// events, even if we didn't finish processing all the queued events.
- qEventDispatcherDebug() << "Top level processEvents was interrupted";
+ qCDebug(lcEventDispatcher) << "Top level processEvents was interrupted";
break;
}
}
@@ -353,7 +347,7 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
// date in the past (overdue) will fire on the next run loop pass. The Qt
// APIs on the other hand document eg. zero-interval timers to always be
// handled after processing all available window-system events.
- qEventDispatcherDebug() << "Manually processing timers due to overdue timer";
+ qCDebug(lcEventDispatcher) << "Manually processing timers due to overdue timer";
processTimers(0);
eventsProcessed = true;
}
@@ -372,7 +366,7 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
if (m_processEvents.deferredWakeUp) {
m_postedEventsRunLoopSource.signal();
- qEventDispatcherDebug() << "Processed deferred wake-up";
+ qCDebug(lcEventDispatcher) << "Processed deferred wake-up";
}
bool wasInterrupted = m_processEvents.wasInterrupted;
@@ -385,11 +379,11 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
// others below it (eg, in the case of nested event loops). We need to trigger
// another interrupt so that the parent processEvents call has a chance to check
// if it should continue.
- qEventDispatcherDebug() << "Forwarding interrupt in case of nested processEvents";
+ qCDebug(lcEventDispatcher) << "Forwarding interrupt in case of nested processEvents";
interrupt();
}
- qEventDispatcherDebug() << "Returning with eventsProcessed = " << eventsProcessed; qUnIndent();
+ qCDebug(lcEventDispatcher) << "Returning with eventsProcessed =" << eventsProcessed;
return eventsProcessed;
}
@@ -397,15 +391,14 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
bool QEventDispatcherCoreFoundation::processPostedEvents()
{
if (m_processEvents.processedPostedEvents && !(m_processEvents.flags & QEventLoop::EventLoopExec)) {
- qEventDispatcherDebug() << "Already processed events this pass";
+ qCDebug(lcEventDispatcher) << "Already processed events this pass";
return false;
}
m_processEvents.processedPostedEvents = true;
- qEventDispatcherDebug() << "Sending posted events for " << m_processEvents.flags; qIndent();
+ qCDebug(lcEventDispatcher) << "Sending posted events for" << m_processEvents.flags;
QCoreApplication::sendPostedEvents();
- qUnIndent();
return true;
}
@@ -413,12 +406,12 @@ bool QEventDispatcherCoreFoundation::processPostedEvents()
void QEventDispatcherCoreFoundation::processTimers(CFRunLoopTimerRef timer)
{
if (m_processEvents.processedTimers && !(m_processEvents.flags & QEventLoop::EventLoopExec)) {
- qEventDispatcherDebug() << "Already processed timers this pass";
+ qCDebug(lcEventDispatcher) << "Already processed timers this pass";
m_processEvents.deferredUpdateTimers = true;
return;
}
- qEventDispatcherDebug() << "CFRunLoopTimer " << timer << " fired, activating Qt timers"; qIndent();
+ qCDebug(lcEventDispatcher) << "CFRunLoopTimer" << timer << "fired, activating Qt timers";
// Activating Qt timers might recurse into processEvents() if a timer-callback
// brings up a new event-loop or tries to processes events manually. Although
@@ -436,15 +429,15 @@ void QEventDispatcherCoreFoundation::processTimers(CFRunLoopTimerRef timer)
m_blockedRunLoopTimer = previouslyBlockedRunLoopTimer;
m_processEvents.processedTimers = true;
- qUnIndent();
-
// Now that the timer source is unblocked we may need to schedule it again
updateTimers();
}
+Q_LOGGING_CATEGORY(lcEventDispatcherActivity, "qt.eventdispatcher.activity")
+
void QEventDispatcherCoreFoundation::handleRunLoopActivity(CFRunLoopActivity activity)
{
- qEventDispatcherDebug() << qPrintableActivity(activity);
+ qCDebug(lcEventDispatcherActivity) << "Runloop entered activity" << qPrintableActivity(activity);
switch (activity) {
case kCFRunLoopBeforeWaiting:
@@ -463,13 +456,11 @@ void QEventDispatcherCoreFoundation::handleRunLoopActivity(CFRunLoopActivity act
case kCFRunLoopAfterWaiting:
emit awake();
break;
-#if DEBUG_EVENT_DISPATCHER
case kCFRunLoopEntry:
case kCFRunLoopBeforeTimers:
case kCFRunLoopBeforeSources:
case kCFRunLoopExit:
break;
-#endif
default:
Q_UNREACHABLE();
}
@@ -502,19 +493,19 @@ void QEventDispatcherCoreFoundation::wakeUp()
// posted event gets processed on the next processEvents() call, so we flag the
// need to do a deferred wake-up.
m_processEvents.deferredWakeUp = true;
- qEventDispatcherDebug() << "Already processed posted events, deferring wakeUp";
+ qCDebug(lcEventDispatcher) << "Already processed posted events, deferring wakeUp";
return;
}
m_postedEventsRunLoopSource.signal();
CFRunLoopWakeUp(CFRunLoopGetMain());
- qEventDispatcherDebug() << "Signaled posted event run-loop source";
+ qCDebug(lcEventDispatcher) << "Signaled posted event run-loop source";
}
void QEventDispatcherCoreFoundation::interrupt()
{
- qEventDispatcherDebug() << "Marking current processEvent as interrupted";
+ qCDebug(lcEventDispatcher) << "Marking current processEvent as interrupted";
m_processEvents.wasInterrupted = true;
CFRunLoopStop(CFRunLoopGetMain());
}
@@ -540,8 +531,8 @@ void QEventDispatcherCoreFoundation::unregisterSocketNotifier(QSocketNotifier *n
void QEventDispatcherCoreFoundation::registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object)
{
- qEventDispatcherDebug() << "id = " << timerId << ", interval = " << interval
- << ", type = " << timerType << ", object = " << object;
+ qCDebug(lcEventDispatcherTimers) << "Registering timer with id =" << timerId << "interval =" << interval
+ << "type =" << timerType << "object =" << object;
Q_ASSERT(timerId > 0 && interval >= 0 && object);
Q_ASSERT(object->thread() == thread() && thread() == QThread::currentThread());
@@ -557,7 +548,7 @@ bool QEventDispatcherCoreFoundation::unregisterTimer(int timerId)
bool returnValue = m_timerInfoList.unregisterTimer(timerId);
- qEventDispatcherDebug() << "id = " << timerId << ", timers left: " << m_timerInfoList.size();
+ qCDebug(lcEventDispatcherTimers) << "Unegistered timer with id =" << timerId << "Timers left:" << m_timerInfoList.size();
updateTimers();
return returnValue;
@@ -569,7 +560,7 @@ bool QEventDispatcherCoreFoundation::unregisterTimers(QObject *object)
bool returnValue = m_timerInfoList.unregisterTimers(object);
- qEventDispatcherDebug() << "object = " << object << ", timers left: " << m_timerInfoList.size();
+ qCDebug(lcEventDispatcherTimers) << "Unegistered timers for object =" << object << "Timers left:" << m_timerInfoList.size();
updateTimers();
return returnValue;
@@ -612,16 +603,16 @@ void QEventDispatcherCoreFoundation::updateTimers()
});
CFRunLoopAddTimer(CFRunLoopGetMain(), m_runLoopTimer, kCFRunLoopCommonModes);
- qEventDispatcherDebug() << "Created new CFRunLoopTimer " << m_runLoopTimer;
+ qCDebug(lcEventDispatcherTimers) << "Created new CFRunLoopTimer" << m_runLoopTimer;
} else {
CFRunLoopTimerSetNextFireDate(m_runLoopTimer, timeToFire);
- qEventDispatcherDebug() << "Re-scheduled CFRunLoopTimer " << m_runLoopTimer;
+ qCDebug(lcEventDispatcherTimers) << "Re-scheduled CFRunLoopTimer" << m_runLoopTimer;
}
m_overdueTimerScheduled = !timespecToSeconds(tv);
- qEventDispatcherDebug() << "Next timeout in " << tv << " seconds";
+ qCDebug(lcEventDispatcherTimers) << "Next timeout in" << tv << "seconds";
} else {
// No Qt timers are registered, so make sure we're not running any CF timers
@@ -637,7 +628,7 @@ void QEventDispatcherCoreFoundation::invalidateTimer()
return;
CFRunLoopTimerInvalidate(m_runLoopTimer);
- qEventDispatcherDebug() << "Invalidated CFRunLoopTimer " << m_runLoopTimer;
+ qCDebug(lcEventDispatcherTimers) << "Invalidated CFRunLoopTimer" << m_runLoopTimer;
CFRelease(m_runLoopTimer);
m_runLoopTimer = 0;
diff --git a/src/corelib/kernel/qeventdispatcher_cf_p.h b/src/corelib/kernel/qeventdispatcher_cf_p.h
index 8a234ebc40..a607ab7a15 100644
--- a/src/corelib/kernel/qeventdispatcher_cf_p.h
+++ b/src/corelib/kernel/qeventdispatcher_cf_p.h
@@ -85,19 +85,22 @@
// We mean it.
//
-#define DEBUG_EVENT_DISPATCHER 0
-
#include <QtCore/qabstracteventdispatcher.h>
#include <QtCore/private/qtimerinfo_unix_p.h>
#include <QtCore/private/qcfsocketnotifier_p.h>
#include <QtCore/private/qcore_mac_p.h>
#include <QtCore/qdebug.h>
+#include <QtCore/qloggingcategory.h>
+
#include <CoreFoundation/CoreFoundation.h>
Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(RunLoopModeTracker));
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(lcEventDispatcher);
+Q_DECLARE_LOGGING_CATEGORY(lcEventDispatcherTimers)
+
class QEventDispatcherCoreFoundation;
template <class T = QEventDispatcherCoreFoundation>
@@ -269,17 +272,4 @@ private:
QT_END_NAMESPACE
-#if DEBUG_EVENT_DISPATCHER
-extern uint g_eventDispatcherIndentationLevel;
-#define qEventDispatcherDebug() qDebug().nospace() \
- << qPrintable(QString(QLatin1String("| ")).repeated(g_eventDispatcherIndentationLevel)) \
- << __FUNCTION__ << "(): "
-#define qIndent() ++g_eventDispatcherIndentationLevel
-#define qUnIndent() --g_eventDispatcherIndentationLevel
-#else
-#define qEventDispatcherDebug() QT_NO_QDEBUG_MACRO()
-#define qIndent()
-#define qUnIndent()
-#endif
-
#endif // QEVENTDISPATCHER_CF_P_H
diff --git a/src/corelib/kernel/qeventdispatcher_glib_p.h b/src/corelib/kernel/qeventdispatcher_glib_p.h
index 8e9925d7a5..799f23b14a 100644
--- a/src/corelib/kernel/qeventdispatcher_glib_p.h
+++ b/src/corelib/kernel/qeventdispatcher_glib_p.h
@@ -70,22 +70,22 @@ public:
explicit QEventDispatcherGlib(GMainContext *context, QObject *parent = 0);
~QEventDispatcherGlib();
- bool processEvents(QEventLoop::ProcessEventsFlags flags) Q_DECL_OVERRIDE;
- bool hasPendingEvents() Q_DECL_OVERRIDE;
+ bool processEvents(QEventLoop::ProcessEventsFlags flags) override;
+ bool hasPendingEvents() override;
- void registerSocketNotifier(QSocketNotifier *socketNotifier) Q_DECL_FINAL;
- void unregisterSocketNotifier(QSocketNotifier *socketNotifier) Q_DECL_FINAL;
+ void registerSocketNotifier(QSocketNotifier *socketNotifier) final;
+ void unregisterSocketNotifier(QSocketNotifier *socketNotifier) final;
- void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object) Q_DECL_FINAL;
- bool unregisterTimer(int timerId) Q_DECL_FINAL;
- bool unregisterTimers(QObject *object) Q_DECL_FINAL;
- QList<TimerInfo> registeredTimers(QObject *object) const Q_DECL_FINAL;
+ void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object) final;
+ bool unregisterTimer(int timerId) final;
+ bool unregisterTimers(QObject *object) final;
+ QList<TimerInfo> registeredTimers(QObject *object) const final;
- int remainingTime(int timerId) Q_DECL_FINAL;
+ int remainingTime(int timerId) final;
- void wakeUp() Q_DECL_FINAL;
- void interrupt() Q_DECL_FINAL;
- void flush() Q_DECL_FINAL;
+ void wakeUp() final;
+ void interrupt() final;
+ void flush() final;
static bool versionSupported();
diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h
index bcf5b10baa..0fd068b074 100644
--- a/src/corelib/kernel/qeventdispatcher_unix_p.h
+++ b/src/corelib/kernel/qeventdispatcher_unix_p.h
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
class QEventDispatcherUNIXPrivate;
-struct Q_CORE_EXPORT QSocketNotifierSetUNIX Q_DECL_FINAL
+struct Q_CORE_EXPORT QSocketNotifierSetUNIX final
{
inline QSocketNotifierSetUNIX() Q_DECL_NOTHROW;
@@ -105,22 +105,22 @@ public:
explicit QEventDispatcherUNIX(QObject *parent = 0);
~QEventDispatcherUNIX();
- bool processEvents(QEventLoop::ProcessEventsFlags flags) Q_DECL_OVERRIDE;
- bool hasPendingEvents() Q_DECL_OVERRIDE;
+ bool processEvents(QEventLoop::ProcessEventsFlags flags) override;
+ bool hasPendingEvents() override;
- void registerSocketNotifier(QSocketNotifier *notifier) Q_DECL_FINAL;
- void unregisterSocketNotifier(QSocketNotifier *notifier) Q_DECL_FINAL;
+ void registerSocketNotifier(QSocketNotifier *notifier) final;
+ void unregisterSocketNotifier(QSocketNotifier *notifier) final;
- void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object) Q_DECL_FINAL;
- bool unregisterTimer(int timerId) Q_DECL_FINAL;
- bool unregisterTimers(QObject *object) Q_DECL_FINAL;
- QList<TimerInfo> registeredTimers(QObject *object) const Q_DECL_FINAL;
+ void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object) final;
+ bool unregisterTimer(int timerId) final;
+ bool unregisterTimers(QObject *object) final;
+ QList<TimerInfo> registeredTimers(QObject *object) const final;
- int remainingTime(int timerId) Q_DECL_FINAL;
+ int remainingTime(int timerId) final;
- void wakeUp() Q_DECL_FINAL;
- void interrupt() Q_DECL_FINAL;
- void flush() Q_DECL_OVERRIDE;
+ void wakeUp() final;
+ void interrupt() final;
+ void flush() override;
protected:
QEventDispatcherUNIX(QEventDispatcherUNIXPrivate &dd, QObject *parent = 0);
diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp
index 8974ff7709..6034698349 100644
--- a/src/corelib/kernel/qeventloop.cpp
+++ b/src/corelib/kernel/qeventloop.cpp
@@ -101,8 +101,10 @@ QEventLoop::QEventLoop(QObject *parent)
Q_D(QEventLoop);
if (!QCoreApplication::instance() && QCoreApplicationPrivate::threadRequiresCoreApplication()) {
qWarning("QEventLoop: Cannot be used without QApplication");
- } else if (!d->threadData->eventDispatcher.load()) {
- QThreadPrivate::createEventDispatcher(d->threadData);
+ } else if (!d->threadData->hasEventDispatcher()) {
+ QAbstractEventDispatcher *eventDispatcher = QThreadPrivate::createEventDispatcher(d->threadData);
+ d->threadData->eventDispatcher.storeRelease(eventDispatcher);
+ eventDispatcher->startingUp();
}
}
@@ -129,7 +131,7 @@ QEventLoop::~QEventLoop()
bool QEventLoop::processEvents(ProcessEventsFlags flags)
{
Q_D(QEventLoop);
- if (!d->threadData->eventDispatcher.load())
+ if (!d->threadData->hasEventDispatcher())
return false;
return d->threadData->eventDispatcher.load()->processEvents(flags);
}
@@ -234,7 +236,7 @@ int QEventLoop::exec(ProcessEventsFlags flags)
void QEventLoop::processEvents(ProcessEventsFlags flags, int maxTime)
{
Q_D(QEventLoop);
- if (!d->threadData->eventDispatcher.load())
+ if (!d->threadData->hasEventDispatcher())
return;
QElapsedTimer start;
@@ -263,7 +265,7 @@ void QEventLoop::processEvents(ProcessEventsFlags flags, int maxTime)
void QEventLoop::exit(int returnCode)
{
Q_D(QEventLoop);
- if (!d->threadData->eventDispatcher.load())
+ if (!d->threadData->hasEventDispatcher())
return;
d->returnCode.store(returnCode);
@@ -292,7 +294,7 @@ bool QEventLoop::isRunning() const
void QEventLoop::wakeUp()
{
Q_D(QEventLoop);
- if (!d->threadData->eventDispatcher.load())
+ if (!d->threadData->hasEventDispatcher())
return;
d->threadData->eventDispatcher.load()->wakeUp();
}
diff --git a/src/corelib/kernel/qeventloop.h b/src/corelib/kernel/qeventloop.h
index e62b1d8419..eb1348220b 100644
--- a/src/corelib/kernel/qeventloop.h
+++ b/src/corelib/kernel/qeventloop.h
@@ -53,7 +53,7 @@ class Q_CORE_EXPORT QEventLoop : public QObject
Q_DECLARE_PRIVATE(QEventLoop)
public:
- explicit QEventLoop(QObject *parent = Q_NULLPTR);
+ explicit QEventLoop(QObject *parent = nullptr);
~QEventLoop();
enum ProcessEventsFlag {
@@ -76,7 +76,7 @@ public:
void wakeUp();
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
public Q_SLOTS:
void quit();
diff --git a/src/corelib/kernel/qfunctions_vxworks.h b/src/corelib/kernel/qfunctions_vxworks.h
index 34630a735b..86f243959f 100644
--- a/src/corelib/kernel/qfunctions_vxworks.h
+++ b/src/corelib/kernel/qfunctions_vxworks.h
@@ -62,9 +62,6 @@
#include <sys/stat.h>
#include <sys/wait.h>
#include <netinet/in.h>
-#ifndef QT_NO_IPV6IFNAME
-#include <net/if.h>
-#endif
// VxWorks has public header mbuf.h which defines following variables for DKM.
// Let's undef those to because they overlap with Qt variable names-
diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp
index 60154328c2..75a2436d9d 100644
--- a/src/corelib/kernel/qjni.cpp
+++ b/src/corelib/kernel/qjni.cpp
@@ -260,7 +260,7 @@ QJNIEnvironmentPrivate::QJNIEnvironmentPrivate()
return;
if (ret == JNI_EDETACHED) { // We need to (re-)attach
- JavaVMAttachArgs args = { JNI_VERSION_1_6, qJniThreadName, Q_NULLPTR };
+ JavaVMAttachArgs args = { JNI_VERSION_1_6, qJniThreadName, nullptr };
if (vm->AttachCurrentThread(&jniEnv, &args) != JNI_OK)
return;
diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp
index 0d7c143999..04c9a9bcba 100644
--- a/src/corelib/kernel/qjnihelpers.cpp
+++ b/src/corelib/kernel/qjnihelpers.cpp
@@ -64,14 +64,14 @@ namespace QtAndroidPrivate {
KeyEventListener::~KeyEventListener() {}
}
-static JavaVM *g_javaVM = Q_NULLPTR;
-static jobject g_jActivity = Q_NULLPTR;
-static jobject g_jService = Q_NULLPTR;
-static jobject g_jClassLoader = Q_NULLPTR;
+static JavaVM *g_javaVM = nullptr;
+static jobject g_jActivity = nullptr;
+static jobject g_jService = nullptr;
+static jobject g_jClassLoader = nullptr;
static jint g_androidSdkVersion = 0;
-static jclass g_jNativeClass = Q_NULLPTR;
-static jmethodID g_runPendingCppRunnablesMethodID = Q_NULLPTR;
-static jmethodID g_hideSplashScreenMethodID = Q_NULLPTR;
+static jclass g_jNativeClass = nullptr;
+static jmethodID g_runPendingCppRunnablesMethodID = nullptr;
+static jmethodID g_hideSplashScreenMethodID = nullptr;
Q_GLOBAL_STATIC(std::deque<QtAndroidPrivate::Runnable>, g_pendingRunnables);
static QBasicMutex g_pendingRunnablesMutex;
diff --git a/src/corelib/kernel/qjnionload.cpp b/src/corelib/kernel/qjnionload.cpp
index 8f60800dba..0550b86553 100644
--- a/src/corelib/kernel/qjnionload.cpp
+++ b/src/corelib/kernel/qjnionload.cpp
@@ -61,7 +61,7 @@ Q_CORE_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
__android_log_print(ANDROID_LOG_INFO, logTag, "Start");
_JNIEnv uenv;
- uenv.venv = Q_NULLPTR;
+ uenv.venv = nullptr;
if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_6) != JNI_OK)
{
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 5c97bc6851..27138dd075 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -1341,7 +1341,7 @@ QByteArray QMetaObject::normalizedSignature(const char *method)
enum { MaximumParamCount = 11 }; // up to 10 arguments + 1 return value
-/*!
+/*
Returns the signatures of all methods whose name matches \a nonExistentMember,
or an empty QByteArray if there are no matches.
*/
@@ -1595,53 +1595,29 @@ bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase *
*/
/*!
- \fn bool QMetaObject::invokeMethod(QObject *receiver, PointerToMemberFunction function, Qt::ConnectionType type = Qt::AutoConnection, MemberFunctionReturnType *ret = Q_NULLPTR)
-
- \since 5.10
-
- \overload
-*/
-
-/*!
- \fn bool QMetaObject::invokeMethod(QObject *receiver, PointerToMemberFunction function, MemberFunctionReturnType *ret)
-
- \since 5.10
-
- \overload
-
- This overload invokes the member function using the connection type Qt::AutoConnection.
-*/
-
-/*!
- \fn bool QMetaObject::invokeMethod(QObject *context, Functor function, Qt::ConnectionType type = Qt::AutoConnection, FunctorReturnType *ret = Q_NULLPTR)
+ \fn template<typename Functor, typename FunctorReturnType> bool QMetaObject::invokeMethod(QObject *context, Functor function, Qt::ConnectionType type, FunctorReturnType *ret)
\since 5.10
\overload
- Call the functor in the event loop of \a context.
+ Invokes the \a function in the event loop of \a context. \a function can be a functor
+ or a pointer to a member function. Returns \c true if the function could be invoked.
+ Returns \c false if there is no such function or the parameters did not match.
+ The return value of the function call is placed in \a ret.
*/
/*!
- \fn bool QMetaObject::invokeMethod(QObject *context, Functor function, FunctorReturnType *ret = Q_NULLPTR)
+ \fn template<typename Functor, typename FunctorReturnType> bool QMetaObject::invokeMethod(QObject *context, Functor function, FunctorReturnType *ret)
\since 5.10
\overload
- Call the functor in the event loop of \a context using the connection type Qt::AutoConnection.
-*/
-
-/*!
- \fn QMetaObject::Connection::Connection(const Connection &other)
-
- Constructs a copy of \a other.
-*/
-
-/*!
- \fn QMetaObject::Connection::Connection &operator=(const Connection &other)
-
- Assigns \a other to this connection and returns a reference to this connection.
+ Invokes the \a function in the event loop of \a context using the connection type Qt::AutoConnection.
+ \a function can be a functor or a pointer to a member function. Returns \c true if the function could
+ be invoked. Returns \c false if there is no such member or the parameters did not match.
+ The return value of the function call is placed in \a ret.
*/
/*!
@@ -2113,7 +2089,7 @@ QMetaMethod::MethodType QMetaMethod::methodType() const
}
/*!
- \fn QMetaMethod QMetaMethod::fromSignal(PointerToMemberFunction signal)
+ \fn template <typename PointerToMemberFunction> QMetaMethod QMetaMethod::fromSignal(PointerToMemberFunction signal)
\since 5.0
Returns the meta-method that corresponds to the given \a signal, or an
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index 40b2aa6402..51df8faad3 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -54,7 +54,7 @@ template <typename T> class QList;
class Q_CORE_EXPORT QMetaMethod
{
public:
- Q_DECL_CONSTEXPR inline QMetaMethod() : mobj(Q_NULLPTR), handle(0) {}
+ Q_DECL_CONSTEXPR inline QMetaMethod() : mobj(nullptr), handle(0) {}
QByteArray methodSignature() const;
QByteArray name() const;
@@ -80,7 +80,7 @@ public:
bool invoke(QObject *object,
Qt::ConnectionType connectionType,
QGenericReturnArgument returnValue,
- QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
+ QGenericArgument val0 = QGenericArgument(nullptr),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -92,7 +92,7 @@ public:
QGenericArgument val9 = QGenericArgument()) const;
inline bool invoke(QObject *object,
QGenericReturnArgument returnValue,
- QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
+ QGenericArgument val0 = QGenericArgument(nullptr),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -108,7 +108,7 @@ public:
}
inline bool invoke(QObject *object,
Qt::ConnectionType connectionType,
- QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
+ QGenericArgument val0 = QGenericArgument(nullptr),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -123,7 +123,7 @@ public:
val0, val1, val2, val3, val4, val5, val6, val7, val8, val9);
}
inline bool invoke(QObject *object,
- QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
+ QGenericArgument val0 = QGenericArgument(nullptr),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -140,7 +140,7 @@ public:
bool invokeOnGadget(void *gadget,
QGenericReturnArgument returnValue,
- QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
+ QGenericArgument val0 = QGenericArgument(nullptr),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -151,7 +151,7 @@ public:
QGenericArgument val8 = QGenericArgument(),
QGenericArgument val9 = QGenericArgument()) const;
inline bool invokeOnGadget(void *gadget,
- QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
+ QGenericArgument val0 = QGenericArgument(nullptr),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -166,7 +166,7 @@ public:
val0, val1, val2, val3, val4, val5, val6, val7, val8, val9);
}
- inline bool isValid() const { return mobj != Q_NULLPTR; }
+ inline bool isValid() const { return mobj != nullptr; }
template <typename PointerToMemberFunction>
static inline QMetaMethod fromSignal(PointerToMemberFunction signal)
@@ -183,7 +183,7 @@ private:
// signature() has been renamed to methodSignature() in Qt 5.
// Warning, that function returns a QByteArray; check the life time if
// you convert to char*.
- char *signature(struct renamedInQt5_warning_checkTheLifeTime * = Q_NULLPTR) Q_DECL_EQ_DELETE;
+ char *signature(struct renamedInQt5_warning_checkTheLifeTime * = nullptr) Q_DECL_EQ_DELETE;
#endif
static QMetaMethod fromSignalImpl(const QMetaObject *, void **);
@@ -206,7 +206,7 @@ inline bool operator!=(const QMetaMethod &m1, const QMetaMethod &m2)
class Q_CORE_EXPORT QMetaEnum
{
public:
- Q_DECL_CONSTEXPR inline QMetaEnum() : mobj(Q_NULLPTR), handle(0) {}
+ Q_DECL_CONSTEXPR inline QMetaEnum() : mobj(nullptr), handle(0) {}
const char *name() const;
bool isFlag() const;
@@ -218,14 +218,14 @@ public:
const char *scope() const;
- int keyToValue(const char *key, bool *ok = Q_NULLPTR) const;
+ int keyToValue(const char *key, bool *ok = nullptr) const;
const char* valueToKey(int value) const;
- int keysToValue(const char * keys, bool *ok = Q_NULLPTR) const;
+ int keysToValue(const char * keys, bool *ok = nullptr) const;
QByteArray valueToKeys(int value) const;
inline const QMetaObject *enclosingMetaObject() const { return mobj; }
- inline bool isValid() const { return name() != Q_NULLPTR; }
+ inline bool isValid() const { return name() != nullptr; }
template<typename T> static QMetaEnum fromType() {
Q_STATIC_ASSERT_X(QtPrivate::IsQEnumHelper<T>::Value,
@@ -256,11 +256,11 @@ public:
bool isReadable() const;
bool isWritable() const;
bool isResettable() const;
- bool isDesignable(const QObject *obj = Q_NULLPTR) const;
- bool isScriptable(const QObject *obj = Q_NULLPTR) const;
- bool isStored(const QObject *obj = Q_NULLPTR) const;
- bool isEditable(const QObject *obj = Q_NULLPTR) const;
- bool isUser(const QObject *obj = Q_NULLPTR) const;
+ bool isDesignable(const QObject *obj = nullptr) const;
+ bool isScriptable(const QObject *obj = nullptr) const;
+ bool isStored(const QObject *obj = nullptr) const;
+ bool isEditable(const QObject *obj = nullptr) const;
+ bool isUser(const QObject *obj = nullptr) const;
bool isConstant() const;
bool isFinal() const;
@@ -300,7 +300,7 @@ private:
class Q_CORE_EXPORT QMetaClassInfo
{
public:
- Q_DECL_CONSTEXPR inline QMetaClassInfo() : mobj(Q_NULLPTR), handle(0) {}
+ Q_DECL_CONSTEXPR inline QMetaClassInfo() : mobj(nullptr), handle(0) {}
const char *name() const;
const char *value() const;
inline const QMetaObject *enclosingMetaObject() const { return mobj; }
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index e48807ea49..5abc2ebd70 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -216,6 +216,7 @@ struct DefinedTypesFilter {
\value QChar QChar
\value QString QString
\value QByteArray QByteArray
+ \value Nullptr \c{std::nullptr_t}
\value VoidStar \c{void *}
\value Long \c{long}
@@ -287,6 +288,8 @@ struct DefinedTypesFilter {
\value User Base value for user types
\value UnknownType This is an invalid type id. It is returned from QMetaType for types that are not registered
+ \omitvalue LastCoreType
+ \omitvalue LastGuiType
Additional types can be registered using Q_DECLARE_METATYPE().
@@ -586,7 +589,7 @@ Q_GLOBAL_STATIC(QMetaTypeDebugStreamRegistry, customTypesDebugStreamRegistry)
*/
/*!
- \fn bool QMetaType::registerConverter(MemberFunction function)
+ \fn template<typename MemberFunction, int> bool QMetaType::registerConverter(MemberFunction function)
\since 5.2
\overload
Registers a method \a function like To From::function() const as converter from type From
@@ -594,7 +597,7 @@ Q_GLOBAL_STATIC(QMetaTypeDebugStreamRegistry, customTypesDebugStreamRegistry)
*/
/*!
- \fn bool QMetaType::registerConverter(MemberFunctionOk function)
+ \fn template<typename MemberFunctionOk, char> bool QMetaType::registerConverter(MemberFunctionOk function)
\since 5.2
\overload
Registers a method \a function like To From::function(bool *ok) const as converter from type From
@@ -602,7 +605,7 @@ Q_GLOBAL_STATIC(QMetaTypeDebugStreamRegistry, customTypesDebugStreamRegistry)
*/
/*!
- \fn bool QMetaType::registerConverter(UnaryFunction function)
+ \fn template<typename UnaryFunction> bool QMetaType::registerConverter(UnaryFunction function)
\since 5.2
\overload
Registers a unary function object \a function as converter from type From
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index f704c5b21a..455d0350e0 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -234,7 +234,7 @@ struct AbstractDebugStreamFunction
{
typedef void (*Stream)(const AbstractDebugStreamFunction *, QDebug&, const void *);
typedef void (*Destroy)(AbstractDebugStreamFunction *);
- explicit AbstractDebugStreamFunction(Stream s = Q_NULLPTR, Destroy d = Q_NULLPTR)
+ explicit AbstractDebugStreamFunction(Stream s = nullptr, Destroy d = nullptr)
: stream(s), destroy(d) {}
Q_DISABLE_COPY(AbstractDebugStreamFunction)
Stream stream;
@@ -264,7 +264,7 @@ struct AbstractComparatorFunction
typedef bool (*LessThan)(const AbstractComparatorFunction *, const void *, const void *);
typedef bool (*Equals)(const AbstractComparatorFunction *, const void *, const void *);
typedef void (*Destroy)(AbstractComparatorFunction *);
- explicit AbstractComparatorFunction(LessThan lt = Q_NULLPTR, Equals e = Q_NULLPTR, Destroy d = Q_NULLPTR)
+ explicit AbstractComparatorFunction(LessThan lt = nullptr, Equals e = nullptr, Destroy d = nullptr)
: lessThan(lt), equals(e), destroy(d) {}
Q_DISABLE_COPY(AbstractComparatorFunction)
LessThan lessThan;
@@ -301,7 +301,7 @@ template<typename T>
struct BuiltInEqualsComparatorFunction : public AbstractComparatorFunction
{
BuiltInEqualsComparatorFunction()
- : AbstractComparatorFunction(Q_NULLPTR, equals, destroy) {}
+ : AbstractComparatorFunction(nullptr, equals, destroy) {}
static bool equals(const AbstractComparatorFunction *, const void *l, const void *r)
{
const T *lhs = static_cast<const T *>(l);
@@ -318,7 +318,7 @@ struct BuiltInEqualsComparatorFunction : public AbstractComparatorFunction
struct AbstractConverterFunction
{
typedef bool (*Converter)(const AbstractConverterFunction *, const void *, void*);
- explicit AbstractConverterFunction(Converter c = Q_NULLPTR)
+ explicit AbstractConverterFunction(Converter c = nullptr)
: convert(c) {}
Q_DISABLE_COPY(AbstractConverterFunction)
Converter convert;
@@ -406,7 +406,7 @@ class Q_CORE_EXPORT QMetaType {
FlagsEx = 0x100, MetaObjectEx = 0x200
};
public:
-#ifndef Q_QDOC
+#ifndef Q_CLANG_QDOC
// The code that actually gets compiled.
enum Type {
// these are merged with QVariant
@@ -441,6 +441,7 @@ public:
QJsonValue = 45, QJsonObject = 46, QJsonArray = 47, QJsonDocument = 48,
QByteArrayList = 49, QObjectStar = 39, SChar = 40,
Void = 43,
+ Nullptr = 51,
QVariantMap = 8, QVariantList = 9, QVariantHash = 28,
QFont = 64, QPixmap = 65, QBrush = 66, QColor = 67, QPalette = 68,
QIcon = 69, QImage = 70, QPolygon = 71, QRegion = 72, QBitmap = 73,
@@ -448,6 +449,8 @@ public:
QMatrix = 79, QTransform = 80, QMatrix4x4 = 81, QVector2D = 82,
QVector3D = 83, QVector4D = 84, QQuaternion = 85, QPolygonF = 86,
QSizePolicy = 121,
+ LastCoreType = Nullptr,
+ LastGuiType = QPolygonF,
User = 1024
};
#endif
@@ -513,9 +516,9 @@ public:
static TypeFlags typeFlags(int type);
static const QMetaObject *metaObjectForType(int type);
static bool isRegistered(int type);
- static void *create(int type, const void *copy = Q_NULLPTR);
+ static void *create(int type, const void *copy = nullptr);
#if QT_DEPRECATED_SINCE(5, 0)
- QT_DEPRECATED static void *construct(int type, const void *copy = Q_NULLPTR)
+ QT_DEPRECATED static void *construct(int type, const void *copy = nullptr)
{ return create(type, copy); }
#endif
static void destroy(int type, void *data);
@@ -536,9 +539,9 @@ public:
inline TypeFlags flags() const;
inline const QMetaObject *metaObject() const;
- inline void *create(const void *copy = Q_NULLPTR) const;
+ inline void *create(const void *copy = nullptr) const;
inline void destroy(void *data) const;
- inline void *construct(void *where, const void *copy = Q_NULLPTR) const;
+ inline void *construct(void *where, const void *copy = nullptr) const;
inline void destruct(void *data) const;
public:
@@ -596,7 +599,7 @@ public:
return registerConverter<From, To>(QtPrivate::convertImplicit<From, To>);
}
-#ifdef Q_QDOC
+#ifdef Q_CLANG_QDOC
template<typename MemberFunction, int>
static bool registerConverter(MemberFunction function);
template<typename MemberFunctionOk, char>
@@ -617,7 +620,7 @@ public:
return registerConverterFunction(&f, fromTypeId, toTypeId);
}
- // member function as in "double QString::toDouble(bool *ok = Q_NULLPTR) const"
+ // member function as in "double QString::toDouble(bool *ok = nullptr) const"
template<typename From, typename To>
static bool registerConverter(To(From::*function)(bool*) const)
{
@@ -680,9 +683,9 @@ private:
uint sizeExtended() const;
QMetaType::TypeFlags flagsExtended() const;
const QMetaObject *metaObjectExtended() const;
- void *createExtended(const void *copy = Q_NULLPTR) const;
+ void *createExtended(const void *copy = nullptr) const;
void destroyExtended(void *data) const;
- void *constructExtended(void *where, const void *copy = Q_NULLPTR) const;
+ void *constructExtended(void *where, const void *copy = nullptr) const;
void destructExtended(void *data) const;
static bool registerComparatorFunction(const QtPrivate::AbstractComparatorFunction *f, int type);
@@ -692,7 +695,7 @@ private:
// ### Qt6: FIXME: Remove the special Q_CC_MSVC handling, it was introduced to maintain BC.
#if !defined(Q_NO_TEMPLATE_FRIENDS) && !defined(Q_CC_MSVC)
-#ifndef Q_QDOC
+#ifndef Q_CLANG_QDOC
template<typename, bool> friend struct QtPrivate::ValueTypeIsMetaType;
template<typename, typename> friend struct QtPrivate::ConverterMemberFunction;
template<typename, typename> friend struct QtPrivate::ConverterMemberFunctionOk;
@@ -782,7 +785,7 @@ struct QMetaTypeFunctionHelper {
template <typename T>
struct QMetaTypeFunctionHelper<T, /* Accepted */ false> {
static void Destruct(void *) {}
- static void *Construct(void *, const void *) { return Q_NULLPTR; }
+ static void *Construct(void *, const void *) { return nullptr; }
#ifndef QT_NO_DATASTREAM
static void Save(QDataStream &, const void *) {}
static void Load(QDataStream &, void *) {}
@@ -1020,7 +1023,7 @@ public:
public:
template<class T> QSequentialIterableImpl(const T*p)
: _iterable(p)
- , _iterator(Q_NULLPTR)
+ , _iterator(nullptr)
, _metaType_id(qMetaTypeId<typename T::value_type>())
, _metaType_flags(QTypeInfo<typename T::value_type>::isPointer)
, _iteratorCapabilities(ContainerAPI<T>::IteratorCapabilities)
@@ -1037,20 +1040,20 @@ public:
}
QSequentialIterableImpl()
- : _iterable(Q_NULLPTR)
- , _iterator(Q_NULLPTR)
+ : _iterable(nullptr)
+ , _iterator(nullptr)
, _metaType_id(QMetaType::UnknownType)
, _metaType_flags(0)
, _iteratorCapabilities(0)
- , _size(Q_NULLPTR)
- , _at(Q_NULLPTR)
- , _moveToBegin(Q_NULLPTR)
- , _moveToEnd(Q_NULLPTR)
- , _advance(Q_NULLPTR)
- , _get(Q_NULLPTR)
- , _destroyIter(Q_NULLPTR)
- , _equalIter(Q_NULLPTR)
- , _copyIter(Q_NULLPTR)
+ , _size(nullptr)
+ , _at(nullptr)
+ , _moveToBegin(nullptr)
+ , _moveToEnd(nullptr)
+ , _advance(nullptr)
+ , _get(nullptr)
+ , _destroyIter(nullptr)
+ , _equalIter(nullptr)
+ , _copyIter(nullptr)
{
}
@@ -1189,7 +1192,7 @@ public:
public:
template<class T> QAssociativeIterableImpl(const T*p)
: _iterable(p)
- , _iterator(Q_NULLPTR)
+ , _iterator(nullptr)
, _metaType_id_key(qMetaTypeId<typename T::key_type>())
, _metaType_flags_key(QTypeInfo<typename T::key_type>::isPointer)
, _metaType_id_value(qMetaTypeId<typename T::mapped_type>())
@@ -1208,22 +1211,22 @@ public:
}
QAssociativeIterableImpl()
- : _iterable(Q_NULLPTR)
- , _iterator(Q_NULLPTR)
+ : _iterable(nullptr)
+ , _iterator(nullptr)
, _metaType_id_key(QMetaType::UnknownType)
, _metaType_flags_key(0)
, _metaType_id_value(QMetaType::UnknownType)
, _metaType_flags_value(0)
- , _size(Q_NULLPTR)
- , _find(Q_NULLPTR)
- , _begin(Q_NULLPTR)
- , _end(Q_NULLPTR)
- , _advance(Q_NULLPTR)
- , _getKey(Q_NULLPTR)
- , _getValue(Q_NULLPTR)
- , _destroyIter(Q_NULLPTR)
- , _equalIter(Q_NULLPTR)
- , _copyIter(Q_NULLPTR)
+ , _size(nullptr)
+ , _find(nullptr)
+ , _begin(nullptr)
+ , _end(nullptr)
+ , _advance(nullptr)
+ , _getKey(nullptr)
+ , _getValue(nullptr)
+ , _destroyIter(nullptr)
+ , _equalIter(nullptr)
+ , _copyIter(nullptr)
{
}
@@ -1292,13 +1295,13 @@ public:
}
QPairVariantInterfaceImpl()
- : _pair(Q_NULLPTR)
+ : _pair(nullptr)
, _metaType_id_first(QMetaType::UnknownType)
, _metaType_flags_first(0)
, _metaType_id_second(QMetaType::UnknownType)
, _metaType_flags_second(0)
- , _getFirst(Q_NULLPTR)
- , _getSecond(Q_NULLPTR)
+ , _getFirst(nullptr)
+ , _getSecond(nullptr)
{
}
@@ -1374,7 +1377,7 @@ namespace QtPrivate
#endif
static no_type checkType(...);
Q_STATIC_ASSERT_X(sizeof(T), "Type argument of Q_DECLARE_METATYPE(T*) must be fully defined");
- enum { Value = sizeof(checkType(static_cast<T*>(Q_NULLPTR))) == sizeof(yes_type) };
+ enum { Value = sizeof(checkType(static_cast<T*>(nullptr))) == sizeof(yes_type) };
};
template<typename T, typename Enable = void>
@@ -1419,12 +1422,12 @@ namespace QtPrivate
template<typename T, typename Enable = void>
struct MetaObjectForType
{
- static inline const QMetaObject *value() { return Q_NULLPTR; }
+ static inline const QMetaObject *value() { return nullptr; }
};
template<>
struct MetaObjectForType<void>
{
- static inline const QMetaObject *value() { return Q_NULLPTR; }
+ static inline const QMetaObject *value() { return nullptr; }
};
template<typename T>
struct MetaObjectForType<T*, typename std::enable_if<IsPointerToTypeDerivedFromQObject<T*>::Value>::type>
@@ -1682,7 +1685,7 @@ namespace QtPrivate {
template <typename T>
int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName
-#ifndef Q_QDOC
+#ifndef Q_CLANG_QDOC
, T * dummy = 0
, typename QtPrivate::MetaTypeDefinedHelper<T, QMetaTypeId2<T>::Defined && !QMetaTypeId2<T>::IsBuiltIn>::DefinedType defined = QtPrivate::MetaTypeDefinedHelper<T, QMetaTypeId2<T>::Defined && !QMetaTypeId2<T>::IsBuiltIn>::Defined
#endif
@@ -1719,8 +1722,8 @@ int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normaliz
template <typename T>
int qRegisterMetaType(const char *typeName
-#ifndef Q_QDOC
- , T * dummy = Q_NULLPTR
+#ifndef Q_CLANG_QDOC
+ , T * dummy = nullptr
, typename QtPrivate::MetaTypeDefinedHelper<T, QMetaTypeId2<T>::Defined && !QMetaTypeId2<T>::IsBuiltIn>::DefinedType defined = QtPrivate::MetaTypeDefinedHelper<T, QMetaTypeId2<T>::Defined && !QMetaTypeId2<T>::IsBuiltIn>::Defined
#endif
)
@@ -1736,8 +1739,8 @@ int qRegisterMetaType(const char *typeName
#ifndef QT_NO_DATASTREAM
template <typename T>
void qRegisterMetaTypeStreamOperators(const char *typeName
-#ifndef Q_QDOC
- , T * /* dummy */ = Q_NULLPTR
+#ifndef Q_CLANG_QDOC
+ , T * /* dummy */ = nullptr
#endif
)
{
@@ -1760,7 +1763,7 @@ inline Q_DECL_CONSTEXPR int qRegisterMetaType()
return qMetaTypeId<T>();
}
-#if QT_DEPRECATED_SINCE(5, 1) && !defined(Q_QDOC)
+#if QT_DEPRECATED_SINCE(5, 1) && !defined(Q_CLANG_QDOC)
// There used to be a T *dummy = 0 argument in Qt 4.0 to support MSVC6
template <typename T>
QT_DEPRECATED inline Q_DECL_CONSTEXPR int qMetaTypeId(T *)
@@ -1932,7 +1935,7 @@ QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_FORWARD_DECLARE_STATIC_TYPES_ITER)
typedef QList<QVariant> QVariantList;
typedef QMap<QString, QVariant> QVariantMap;
typedef QHash<QString, QVariant> QVariantHash;
-#ifndef Q_QDOC
+#ifndef Q_CLANG_QDOC
typedef QList<QByteArray> QByteArrayList;
#endif
@@ -2150,7 +2153,7 @@ inline QMetaType::QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeI
, m_loadOp(loadOp)
, m_constructor(constructor)
, m_destructor(destructor)
- , m_extension(Q_NULLPTR)
+ , m_extension(nullptr)
, m_size(size)
, m_typeFlags(theTypeFlags)
, m_extensionFlags(extensionFlags)
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index baed659590..9e1c3a50cb 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -238,7 +238,7 @@ QObjectPrivate::~QObjectPrivate()
if (extraData && !extraData->runningTimers.isEmpty()) {
if (Q_LIKELY(threadData->thread == QThread::currentThread())) {
// unregister pending timers
- if (threadData->eventDispatcher.load())
+ if (threadData->hasEventDispatcher())
threadData->eventDispatcher.load()->unregisterTimers(q_ptr);
// release the timer ids back to the pool
@@ -516,7 +516,7 @@ void QMetaCallEvent::placeMetaCall(QObject *object)
\reentrant
- QSignalBlocker can be used whereever you would otherwise use a
+ QSignalBlocker can be used wherever you would otherwise use a
pair of calls to blockSignals(). It blocks signals in its
constructor and in the destructor it resets the state to what
it was before the constructor ran.
@@ -999,7 +999,7 @@ QObject::~QObject()
if (senderLists)
senderLists->dirty = true;
- QtPrivate::QSlotObjectBase *slotObj = Q_NULLPTR;
+ QtPrivate::QSlotObjectBase *slotObj = nullptr;
if (node->isSlotObject) {
slotObj = node->slotObj;
node->isSlotObject = false;
@@ -1045,7 +1045,7 @@ QObjectPrivate::Connection::~Connection()
/*!
- \fn QMetaObject *QObject::metaObject() const
+ \fn const QMetaObject *QObject::metaObject() const
Returns a pointer to the meta-object of this object.
@@ -1093,7 +1093,9 @@ QObjectPrivate::Connection::~Connection()
\sa metaObject()
*/
-/*! \fn T *qobject_cast<T *>(QObject *object)
+/*!
+ \fn template <class T> T qobject_cast(QObject *object)
+ \fn template <class T> T qobject_cast(const QObject *object)
\relates QObject
Returns the given \a object cast to type T if the object is of type
@@ -1469,14 +1471,14 @@ void QObject::moveToThread(QThread *targetThread)
}
QThreadData *currentData = QThreadData::current();
- QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : Q_NULLPTR;
+ QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
if (d->threadData->thread == 0 && currentData == targetData) {
// one exception to the rule: we allow moving objects with no thread affinity to the current thread
currentData = d->threadData;
} else if (d->threadData != currentData) {
qWarning("QObject::moveToThread: Current thread (%p) is not the object's thread (%p).\n"
"Cannot move to target thread (%p)\n",
- currentData->thread.load(), d->threadData->thread.load(), targetData ? targetData->thread.load() : Q_NULLPTR);
+ currentData->thread.load(), d->threadData->thread.load(), targetData ? targetData->thread.load() : nullptr);
#ifdef Q_OS_MAC
qWarning("You might be loading two sets of Qt binaries into the same process. "
@@ -1536,7 +1538,7 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData
++eventsMoved;
}
}
- if (eventsMoved > 0 && targetData->eventDispatcher.load()) {
+ if (eventsMoved > 0 && targetData->hasEventDispatcher()) {
targetData->canWait = false;
targetData->eventDispatcher.load()->wakeUp();
}
@@ -1619,7 +1621,7 @@ int QObject::startTimer(int interval, Qt::TimerType timerType)
qWarning("QObject::startTimer: Timers cannot have negative intervals");
return 0;
}
- if (Q_UNLIKELY(!d->threadData->eventDispatcher.load())) {
+ if (Q_UNLIKELY(!d->threadData->hasEventDispatcher())) {
qWarning("QObject::startTimer: Timers can only be used with threads started with QThread");
return 0;
}
@@ -1701,7 +1703,7 @@ void QObject::killTimer(int id)
return;
}
- if (d->threadData->eventDispatcher.load())
+ if (d->threadData->hasEventDispatcher())
d->threadData->eventDispatcher.load()->unregisterTimer(id);
d->extraData->runningTimers.remove(at);
@@ -1743,7 +1745,7 @@ void QObject::killTimer(int id)
/*!
- \fn T *QObject::findChild(const QString &name, Qt::FindChildOptions options) const
+ \fn template<typename T> T *QObject::findChild(const QString &name, Qt::FindChildOptions options) const
Returns the child of this object that can be cast into type T and
that is called \a name, or 0 if there is no such object.
@@ -1780,7 +1782,7 @@ void QObject::killTimer(int id)
*/
/*!
- \fn QList<T> QObject::findChildren(const QString &name, Qt::FindChildOptions options) const
+ \fn template<typename T> QList<T> QObject::findChildren(const QString &name, Qt::FindChildOptions options) const
Returns all children of this object with the given \a name that can be
cast to type T, or an empty list if there are no such objects.
@@ -1805,7 +1807,7 @@ void QObject::killTimer(int id)
*/
/*!
- \fn QList<T> QObject::findChildren(const QRegExp &regExp, Qt::FindChildOptions options) const
+ \fn template<typename T> QList<T> QObject::findChildren(const QRegExp &regExp, Qt::FindChildOptions options) const
\overload findChildren()
Returns the children of this object that can be cast to type T
@@ -1829,7 +1831,7 @@ void QObject::killTimer(int id)
*/
/*!
- \fn T qFindChild(const QObject *obj, const QString &name)
+ \fn template<typename T> T qFindChild(const QObject *obj, const QString &name)
\relates QObject
\overload qFindChildren()
\obsolete
@@ -1845,7 +1847,7 @@ void QObject::killTimer(int id)
*/
/*!
- \fn QList<T> qFindChildren(const QObject *obj, const QString &name)
+ \fn template<typename T> QList<T> qFindChildren(const QObject *obj, const QString &name)
\relates QObject
\overload qFindChildren()
\obsolete
@@ -1861,7 +1863,7 @@ void QObject::killTimer(int id)
*/
/*!
- \fn QList<T> qFindChildren(const QObject *obj, const QRegExp &regExp)
+ \fn template<typename T> QList<T> qFindChildren(const QObject *obj, const QRegExp &regExp)
\relates QObject
\overload qFindChildren()
@@ -2128,7 +2130,7 @@ void QObject::removeEventFilter(QObject *obj)
/*!
- \fn QObject::destroyed(QObject *obj)
+ \fn void QObject::destroyed(QObject *obj)
This signal is emitted immediately before the object \a obj is
destroyed, and can not be blocked.
@@ -4600,7 +4602,7 @@ void qDeleteInEventHandler(QObject *o)
}
/*!
- \fn QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
+ \fn template<typename PointerToMemberFunction> QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
\overload connect()
\threadsafe
@@ -4664,7 +4666,7 @@ void qDeleteInEventHandler(QObject *o)
*/
/*!
- \fn QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
+ \fn template<typename PointerToMemberFunction, typename Functor> QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
\threadsafe
\overload connect()
@@ -4698,7 +4700,7 @@ void qDeleteInEventHandler(QObject *o)
*/
/*!
- \fn QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
+ \fn template<typename PointerToMemberFunction, typename Functor> QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
\threadsafe
\overload connect()
@@ -4896,7 +4898,7 @@ bool QObject::disconnect(const QMetaObject::Connection &connection)
return true;
}
-/*! \fn bool QObject::disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
+/*! \fn template<typename PointerToMemberFunction> bool QObject::disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
\overload diconnect()
\threadsafe
@@ -5025,7 +5027,7 @@ bool QObjectPrivate::disconnect(const QObject *sender, int signal_index, void **
*/
/*!
- Create a copy of the handle to the connection
+ Create a copy of the handle to the \a other connection
*/
QMetaObject::Connection::Connection(const QMetaObject::Connection &other) : d_ptr(other.d_ptr)
{
@@ -5033,6 +5035,9 @@ QMetaObject::Connection::Connection(const QMetaObject::Connection &other) : d_pt
static_cast<QObjectPrivate::Connection *>(d_ptr)->ref();
}
+/*!
+ Assigns \a other to this connection and returns a reference to this connection.
+*/
QMetaObject::Connection& QMetaObject::Connection::operator=(const QMetaObject::Connection& other)
{
if (other.d_ptr != d_ptr) {
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 7299a2b48d..0e608a3208 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -121,23 +121,17 @@ class Q_CORE_EXPORT QObject
Q_DECLARE_PRIVATE(QObject)
public:
- Q_INVOKABLE explicit QObject(QObject *parent=Q_NULLPTR);
+ Q_INVOKABLE explicit QObject(QObject *parent=nullptr);
virtual ~QObject();
virtual bool event(QEvent *event);
virtual bool eventFilter(QObject *watched, QEvent *event);
-#ifdef Q_QDOC
- static QString tr(const char *sourceText, const char *comment = Q_NULLPTR, int n = -1);
- static QString trUtf8(const char *sourceText, const char *comment = Q_NULLPTR, int n = -1);
- virtual const QMetaObject *metaObject() const;
- static const QMetaObject staticMetaObject;
-#endif
-#ifdef QT_NO_TRANSLATION
- static QString tr(const char *sourceText, const char * = Q_NULLPTR, int = -1)
+#if defined(QT_NO_TRANSLATION)
+ static QString tr(const char *sourceText, const char * = nullptr, int = -1)
{ return QString::fromUtf8(sourceText); }
#if QT_DEPRECATED_SINCE(5, 0)
- QT_DEPRECATED static QString trUtf8(const char *sourceText, const char * = Q_NULLPTR, int = -1)
+ QT_DEPRECATED static QString trUtf8(const char *sourceText, const char * = nullptr, int = -1)
{ return QString::fromUtf8(sourceText); }
#endif
#endif //QT_NO_TRANSLATION
@@ -155,7 +149,7 @@ public:
void moveToThread(QThread *thread);
int startTimer(int interval, Qt::TimerType timerType = Qt::CoarseTimer);
-#if QT_HAS_INCLUDE(<chrono>) || defined(Q_QDOC)
+#if QT_HAS_INCLUDE(<chrono>)
Q_ALWAYS_INLINE
int startTimer(std::chrono::milliseconds time, Qt::TimerType timerType = Qt::CoarseTimer)
{
@@ -221,7 +215,7 @@ public:
inline QMetaObject::Connection connect(const QObject *sender, const char *signal,
const char *member, Qt::ConnectionType type = Qt::AutoConnection) const;
-#ifdef Q_QDOC
+#ifdef Q_CLANG_QDOC
template<typename PointerToMemberFunction>
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type = Qt::AutoConnection);
template<typename PointerToMemberFunction, typename Functor>
@@ -249,7 +243,7 @@ public:
Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
"Return type of the slot is not compatible with the return type of the signal.");
- const int *types = Q_NULLPTR;
+ const int *types = nullptr;
if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types();
@@ -289,11 +283,11 @@ public:
Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
"Return type of the slot is not compatible with the return type of the signal.");
- const int *types = Q_NULLPTR;
+ const int *types = nullptr;
if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types();
- return connectImpl(sender, reinterpret_cast<void **>(&signal), context, Q_NULLPTR,
+ return connectImpl(sender, reinterpret_cast<void **>(&signal), context, nullptr,
new QtPrivate::QStaticSlotObject<Func2,
typename QtPrivate::List_Left<typename SignalType::Arguments, SlotType::ArgumentCount>::Value,
typename SignalType::ReturnType>(slot),
@@ -328,30 +322,30 @@ public:
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
"No Q_OBJECT in the class with the signal");
- const int *types = Q_NULLPTR;
+ const int *types = nullptr;
if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types();
- return connectImpl(sender, reinterpret_cast<void **>(&signal), context, Q_NULLPTR,
+ return connectImpl(sender, reinterpret_cast<void **>(&signal), context, nullptr,
new QtPrivate::QFunctorSlotObject<Func2, SlotArgumentCount,
typename QtPrivate::List_Left<typename SignalType::Arguments, SlotArgumentCount>::Value,
typename SignalType::ReturnType>(std::move(slot)),
type, types, &SignalType::Object::staticMetaObject);
}
-#endif //Q_QDOC
+#endif //Q_CLANG_QDOC
static bool disconnect(const QObject *sender, const char *signal,
const QObject *receiver, const char *member);
static bool disconnect(const QObject *sender, const QMetaMethod &signal,
const QObject *receiver, const QMetaMethod &member);
- inline bool disconnect(const char *signal = Q_NULLPTR,
- const QObject *receiver = Q_NULLPTR, const char *member = Q_NULLPTR) const
+ inline bool disconnect(const char *signal = nullptr,
+ const QObject *receiver = nullptr, const char *member = nullptr) const
{ return disconnect(this, signal, receiver, member); }
- inline bool disconnect(const QObject *receiver, const char *member = Q_NULLPTR) const
- { return disconnect(this, Q_NULLPTR, receiver, member); }
+ inline bool disconnect(const QObject *receiver, const char *member = nullptr) const
+ { return disconnect(this, nullptr, receiver, member); }
static bool disconnect(const QMetaObject::Connection &);
-#ifdef Q_QDOC
+#ifdef Q_CLANG_QDOC
template<typename PointerToMemberFunction>
static bool disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method);
#else
@@ -376,7 +370,7 @@ public:
static inline bool disconnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
const QObject *receiver, void **zero)
{
- // This is the overload for when one wish to disconnect a signal from any slot. (slot=Q_NULLPTR)
+ // This is the overload for when one wish to disconnect a signal from any slot. (slot=nullptr)
// Since the function template parameter cannot be deduced from '0', we use a
// dummy void ** parameter that must be equal to 0
Q_ASSERT(!zero);
@@ -384,7 +378,7 @@ public:
return disconnectImpl(sender, reinterpret_cast<void **>(&signal), receiver, zero,
&SignalType::Object::staticMetaObject);
}
-#endif //Q_QDOC
+#endif //Q_CLANG_QDOC
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
@@ -407,14 +401,14 @@ public:
#endif // QT_NO_USERDATA
Q_SIGNALS:
- void destroyed(QObject * = Q_NULLPTR);
+ void destroyed(QObject * = nullptr);
void objectNameChanged(const QString &objectName, QPrivateSignal);
public:
inline QObject *parent() const { return d_ptr->parent; }
inline bool inherits(const char *classname) const
- { return const_cast<QObject *>(this)->qt_metacast(classname) != Q_NULLPTR; }
+ { return const_cast<QObject *>(this)->qt_metacast(classname) != nullptr; }
public Q_SLOTS:
void deleteLater();
@@ -433,7 +427,7 @@ protected:
virtual void disconnectNotify(const QMetaMethod &signal);
protected:
- QObject(QObjectPrivate &dd, QObject *parent = Q_NULLPTR);
+ QObject(QObjectPrivate &dd, QObject *parent = nullptr);
protected:
QScopedPointer<QObjectData> d_ptr;
@@ -480,11 +474,6 @@ public:
};
#endif
-#ifdef Q_QDOC
-T qFindChild(const QObject *o, const QString &name = QString());
-QList<T> qFindChildren(const QObject *oobj, const QString &name = QString());
-QList<T> qFindChildren(const QObject *o, const QRegExp &re);
-#endif
#if QT_DEPRECATED_SINCE(5, 0)
template<typename T>
inline QT_DEPRECATED T qFindChild(const QObject *o, const QString &name = QString())
@@ -496,7 +485,7 @@ inline QT_DEPRECATED QList<T> qFindChildren(const QObject *o, const QString &nam
return o->findChildren<T>(name);
}
-#ifndef QT_NO_REGEXP
+#if !defined(QT_NO_REGEXP) || defined(Q_CLANG_QDOC)
template<typename T>
inline QT_DEPRECATED QList<T> qFindChildren(const QObject *o, const QRegExp &re)
{
@@ -526,16 +515,16 @@ inline T qobject_cast(const QObject *object)
template <class T> inline const char * qobject_interface_iid()
-{ return Q_NULLPTR; }
+{ return nullptr; }
-#ifndef Q_MOC_RUN
+#if !defined(Q_MOC_RUN) && !defined(Q_CLANG_QDOC)
# define Q_DECLARE_INTERFACE(IFace, IId) \
template <> inline const char *qobject_interface_iid<IFace *>() \
{ return IId; } \
template <> inline IFace *qobject_cast<IFace *>(QObject *object) \
- { return reinterpret_cast<IFace *>((object ? object->qt_metacast(IId) : Q_NULLPTR)); } \
+ { return reinterpret_cast<IFace *>((object ? object->qt_metacast(IId) : nullptr)); } \
template <> inline IFace *qobject_cast<IFace *>(const QObject *object) \
- { return reinterpret_cast<IFace *>((object ? const_cast<QObject *>(object)->qt_metacast(IId) : Q_NULLPTR)); }
+ { return reinterpret_cast<IFace *>((object ? const_cast<QObject *>(object)->qt_metacast(IId) : nullptr)); }
#endif // Q_MOC_RUN
#ifndef QT_NO_DEBUG_STREAM
@@ -581,7 +570,7 @@ QSignalBlocker::QSignalBlocker(QSignalBlocker &&other) Q_DECL_NOTHROW
m_blocked(other.m_blocked),
m_inhibited(other.m_inhibited)
{
- other.m_o = Q_NULLPTR;
+ other.m_o = nullptr;
}
QSignalBlocker &QSignalBlocker::operator=(QSignalBlocker &&other) Q_DECL_NOTHROW
@@ -595,7 +584,7 @@ QSignalBlocker &QSignalBlocker::operator=(QSignalBlocker &&other) Q_DECL_NOTHROW
m_blocked = other.m_blocked;
m_inhibited = other.m_inhibited;
// disable other:
- other.m_o = Q_NULLPTR;
+ other.m_o = nullptr;
}
return *this;
}
diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h
index c775d807b1..1a14b93dcd 100644
--- a/src/corelib/kernel/qobject_impl.h
+++ b/src/corelib/kernel/qobject_impl.h
@@ -68,9 +68,9 @@ namespace QtPrivate {
{ enum { Value = QMetaTypeId2<Arg>::Defined && TypesAreDeclaredMetaType<List<Tail...>>::Value }; };
template <typename ArgList, bool Declared = TypesAreDeclaredMetaType<ArgList>::Value > struct ConnectionTypes
- { static const int *types() { return Q_NULLPTR; } };
+ { static const int *types() { return nullptr; } };
template <> struct ConnectionTypes<List<>, true>
- { static const int *types() { return Q_NULLPTR; } };
+ { static const int *types() { return nullptr; } };
template <typename... Args> struct ConnectionTypes<List<Args...>, true>
{ static const int *types() { static const int t[sizeof...(Args) + 1] = { (QtPrivate::QMetaTypeIdHelper<Args>::qt_metatype_id())..., 0 }; return t; } };
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index ad88bcf274..6aea40cf4a 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com>
** Contact: https://www.qt.io/licensing/
**
@@ -145,7 +145,7 @@ public:
ushort connectionType : 3; // 0 == auto, 1 == direct, 2 == queued, 4 == blocking
ushort isSlotObject : 1;
ushort ownArgumentTypes : 1;
- Connection() : nextConnectionList(0), ref_(2), ownArgumentTypes(true) {
+ Connection() : nextConnectionList(nullptr), ref_(2), ownArgumentTypes(true) {
//ref_ is 2 for the use in the internal lists, and for the use in QMetaObject::Connection
}
~Connection();
@@ -160,7 +160,7 @@ public:
};
// ConnectionList is a singly-linked list
struct ConnectionList {
- ConnectionList() : first(0), last(0) {}
+ ConnectionList() : first(nullptr), last(nullptr) {}
Connection *first;
Connection *last;
};
@@ -200,7 +200,7 @@ public:
}
static const QObjectPrivate *get(const QObject *o) { return o->d_func(); }
- int signalIndex(const char *signalName, const QMetaObject **meta = 0) const;
+ int signalIndex(const char *signalName, const QMetaObject **meta = nullptr) const;
inline bool isSignalConnected(uint signalIdx, bool checkDeclarative = true) const;
inline bool isDeclarativeSignalConnected(uint signalIdx) const;
@@ -376,12 +376,12 @@ class Q_CORE_EXPORT QMetaCallEvent : public QEvent
{
public:
QMetaCallEvent(ushort method_offset, ushort method_relative, QObjectPrivate::StaticMetaCallFunction callFunction , const QObject *sender, int signalId,
- int nargs = 0, int *types = 0, void **args = 0, QSemaphore *semaphore = 0);
+ int nargs = 0, int *types = nullptr, void **args = nullptr, QSemaphore *semaphore = nullptr);
/*! \internal
\a signalId is in the signal index range (see QObjectPrivate::signalIndex()).
*/
QMetaCallEvent(QtPrivate::QSlotObjectBase *slotObj, const QObject *sender, int signalId,
- int nargs = 0, int *types = 0, void **args = 0, QSemaphore *semaphore = 0);
+ int nargs = 0, int *types = nullptr, void **args = nullptr, QSemaphore *semaphore = nullptr);
~QMetaCallEvent();
@@ -432,9 +432,9 @@ struct Q_CORE_EXPORT QAbstractDynamicMetaObject : public QDynamicMetaObjectData,
{
~QAbstractDynamicMetaObject();
- virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) Q_DECL_OVERRIDE { return this; }
+ virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) override { return this; }
virtual int createProperty(const char *, const char *) { return -1; }
- virtual int metaCall(QObject *, QMetaObject::Call c, int _id, void **a) Q_DECL_OVERRIDE
+ virtual int metaCall(QObject *, QMetaObject::Call c, int _id, void **a) override
{ return metaCall(c, _id, a); }
virtual int metaCall(QMetaObject::Call, int _id, void **) { return _id; } // Compat overload
};
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 5fc8937f23..d7ed2b0282 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -137,9 +137,9 @@ class QString;
#ifndef QT_NO_TRANSLATION
// full set of tr functions
# define QT_TR_FUNCTIONS \
- static inline QString tr(const char *s, const char *c = Q_NULLPTR, int n = -1) \
+ static inline QString tr(const char *s, const char *c = nullptr, int n = -1) \
{ return staticMetaObject.tr(s, c, n); } \
- QT_DEPRECATED static inline QString trUtf8(const char *s, const char *c = Q_NULLPTR, int n = -1) \
+ QT_DEPRECATED static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) \
{ return staticMetaObject.tr(s, c, n); }
#else
// inherit the ones from QObject
@@ -240,11 +240,6 @@ private: \
#define Q_SLOT Q_SLOT
#endif //Q_MOC_RUN
-#ifdef Q_CLANG_QDOC
-#undef Q_GADGET
-#define Q_GADGET
-#endif
-
#ifndef QT_NO_META_MACROS
// macro for onaming members
#ifdef METHOD
@@ -294,7 +289,7 @@ class QMetaClassInfo;
class Q_CORE_EXPORT QGenericArgument
{
public:
- inline QGenericArgument(const char *aName = Q_NULLPTR, const void *aData = Q_NULLPTR)
+ inline QGenericArgument(const char *aName = nullptr, const void *aData = nullptr)
: _data(aData), _name(aName) {}
inline void *data() const { return const_cast<void *>(_data); }
inline const char *name() const { return _name; }
@@ -307,7 +302,7 @@ private:
class Q_CORE_EXPORT QGenericReturnArgument: public QGenericArgument
{
public:
- inline QGenericReturnArgument(const char *aName = Q_NULLPTR, void *aData = Q_NULLPTR)
+ inline QGenericReturnArgument(const char *aName = nullptr, void *aData = nullptr)
: QGenericArgument(aName, aData)
{}
};
@@ -349,7 +344,7 @@ struct Q_CORE_EXPORT QMetaObject
QObject *cast(QObject *obj) const;
const QObject *cast(const QObject *obj) const;
-#ifndef QT_NO_TRANSLATION
+#if !defined(QT_NO_TRANSLATION) || defined(Q_CLANG_QDOC)
QString tr(const char *s, const char *c, int n = -1) const;
#endif // QT_NO_TRANSLATION
@@ -388,7 +383,7 @@ struct Q_CORE_EXPORT QMetaObject
// internal index-based connect
static Connection connect(const QObject *sender, int signal_index,
const QObject *receiver, int method_index,
- int type = 0, int *types = Q_NULLPTR);
+ int type = 0, int *types = nullptr);
// internal index-based disconnect
static bool disconnect(const QObject *sender, int signal_index,
const QObject *receiver, int method_index);
@@ -405,7 +400,7 @@ struct Q_CORE_EXPORT QMetaObject
static bool invokeMethod(QObject *obj, const char *member,
Qt::ConnectionType,
QGenericReturnArgument ret,
- QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
+ QGenericArgument val0 = QGenericArgument(nullptr),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -418,7 +413,7 @@ struct Q_CORE_EXPORT QMetaObject
static inline bool invokeMethod(QObject *obj, const char *member,
QGenericReturnArgument ret,
- QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
+ QGenericArgument val0 = QGenericArgument(nullptr),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -435,7 +430,7 @@ struct Q_CORE_EXPORT QMetaObject
static inline bool invokeMethod(QObject *obj, const char *member,
Qt::ConnectionType type,
- QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
+ QGenericArgument val0 = QGenericArgument(nullptr),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -451,7 +446,7 @@ struct Q_CORE_EXPORT QMetaObject
}
static inline bool invokeMethod(QObject *obj, const char *member,
- QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
+ QGenericArgument val0 = QGenericArgument(nullptr),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -466,11 +461,7 @@ struct Q_CORE_EXPORT QMetaObject
val1, val2, val3, val4, val5, val6, val7, val8, val9);
}
-#ifdef Q_QDOC
- template<typename PointerToMemberFunction, typename MemberFunctionReturnType>
- static bool invokeMethod(QObject *receiver, PointerToMemberFunction function, Qt::ConnectionType type = Qt::AutoConnection, MemberFunctionReturnType *ret = nullptr);
- template<typename PointerToMemberFunction, typename MemberFunctionReturnType>
- static bool invokeMethod(QObject *receiver, PointerToMemberFunction function, MemberFunctionReturnType *ret);
+#ifdef Q_CLANG_QDOC
template<typename Functor, typename FunctorReturnType>
static bool invokeMethod(QObject *context, Functor function, Qt::ConnectionType type = Qt::AutoConnection, FunctorReturnType *ret = nullptr);
template<typename Functor, typename FunctorReturnType>
@@ -551,7 +542,7 @@ struct Q_CORE_EXPORT QMetaObject
#endif
- QObject *newInstance(QGenericArgument val0 = QGenericArgument(Q_NULLPTR),
+ QObject *newInstance(QGenericArgument val0 = QGenericArgument(nullptr),
QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(),
@@ -611,14 +602,12 @@ public:
operator bool() const;
#else
typedef void *Connection::*RestrictedBool;
- operator RestrictedBool() const { return d_ptr && isConnected_helper() ? &Connection::d_ptr : Q_NULLPTR; }
+ operator RestrictedBool() const { return d_ptr && isConnected_helper() ? &Connection::d_ptr : nullptr; }
#endif
-#ifdef Q_COMPILER_RVALUE_REFS
- inline Connection(Connection &&o) : d_ptr(o.d_ptr) { o.d_ptr = Q_NULLPTR; }
- inline Connection &operator=(Connection &&other)
+ Connection(Connection &&o) Q_DECL_NOTHROW : d_ptr(o.d_ptr) { o.d_ptr = nullptr; }
+ Connection &operator=(Connection &&other) Q_DECL_NOTHROW
{ qSwap(d_ptr, other.d_ptr); return *this; }
-#endif
};
inline const QMetaObject *QMetaObject::superClass() const
diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h
index b9f2e47e32..a6ad00ea22 100644
--- a/src/corelib/kernel/qobjectdefs_impl.h
+++ b/src/corelib/kernel/qobjectdefs_impl.h
@@ -38,8 +38,6 @@
**
****************************************************************************/
-#ifndef Q_QDOC
-
#ifndef QOBJECTDEFS_H
#error Do not include qobjectdefs_impl.h directly
#include <QtCore/qnamespace.h>
@@ -372,10 +370,10 @@ namespace QtPrivate {
inline int ref() Q_DECL_NOTHROW { return m_ref.ref(); }
inline void destroyIfLastRef() Q_DECL_NOTHROW
- { if (!m_ref.deref()) m_impl(Destroy, this, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR); }
+ { if (!m_ref.deref()) m_impl(Destroy, this, nullptr, nullptr, nullptr); }
- inline bool compare(void **a) { bool ret = false; m_impl(Compare, this, Q_NULLPTR, a, &ret); return ret; }
- inline void call(QObject *r, void **a) { m_impl(Call, this, r, a, Q_NULLPTR); }
+ inline bool compare(void **a) { bool ret = false; m_impl(Compare, this, nullptr, a, &ret); return ret; }
+ inline void call(QObject *r, void **a) { m_impl(Call, this, r, a, nullptr); }
protected:
~QSlotObjectBase() {}
private:
@@ -446,4 +444,3 @@ namespace QtPrivate {
QT_END_NAMESPACE
-#endif
diff --git a/src/corelib/kernel/qpointer.cpp b/src/corelib/kernel/qpointer.cpp
index 66495ce005..c3dee7989e 100644
--- a/src/corelib/kernel/qpointer.cpp
+++ b/src/corelib/kernel/qpointer.cpp
@@ -111,7 +111,7 @@
*/
/*!
- \fn QPointer::QPointer()
+ \fn template <class T> QPointer<T>::QPointer()
Constructs a 0 guarded pointer.
@@ -119,14 +119,14 @@
*/
/*!
- \fn QPointer::QPointer(T* p)
+ \fn template <class T> QPointer<T>::QPointer(T* p)
Constructs a guarded pointer that points to the same object that \a p
points to.
*/
/*!
- \fn QPointer::~QPointer()
+ \fn template <class T> QPointer<T>::~QPointer()
Destroys the guarded pointer. Just like a normal pointer,
destroying a guarded pointer does \e not destroy the object being
@@ -134,7 +134,7 @@
*/
/*!
- \fn void QPointer::swap(QPointer &other)
+ \fn template <class T> void QPointer<T>::swap(QPointer &other)
\since 5.6
Swaps the contents of this QPointer with the contents of \a other.
@@ -142,28 +142,28 @@
*/
/*!
- \fn QPointer<T> & QPointer::operator=(T* p)
+ \fn template <class T> QPointer<T> & QPointer<T>::operator=(T* p)
Assignment operator. This guarded pointer will now point to the
same object that \a p points to.
*/
/*!
- \fn T* QPointer::data() const
+ \fn template <class T> T* QPointer<T>::data() const
\since 4.4
Returns the pointer to the object being guarded.
*/
/*!
- \fn bool QPointer::isNull() const
+ \fn template <class T> bool QPointer<T>::isNull() const
Returns \c true if the referenced object has been destroyed or if
there is no referenced object; otherwise returns \c false.
*/
/*!
- \fn void QPointer::clear()
+ \fn template <class T> void QPointer<T>::clear()
\since 5.0
Clears this QPointer object.
@@ -172,21 +172,21 @@
*/
/*!
- \fn T* QPointer::operator->() const
+ \fn template <class T> T* QPointer<T>::operator->() const
Overloaded arrow operator; implements pointer semantics. Just use
this operator as you would with a normal C++ pointer.
*/
/*!
- \fn T& QPointer::operator*() const
+ \fn template <class T> T& QPointer<T>::operator*() const
Dereference operator; implements pointer semantics. Just use this
operator as you would with a normal C++ pointer.
*/
/*!
- \fn QPointer::operator T*() const
+ \fn template <class T> QPointer<T>::operator T*() const
Cast operator; implements pointer semantics. Because of this
function you can pass a QPointer\<T\> to a function where a T*
@@ -194,7 +194,7 @@
*/
/*!
- \fn bool operator==(const T *o, const QPointer<T> &p)
+ \fn template <class T> bool operator==(const T *o, const QPointer<T> &p)
\relates QPointer
Equality operator. Returns \c true if \a o and the guarded
@@ -203,7 +203,7 @@
*/
/*!
- \fn bool operator==(const QPointer<T> &p, const T *o)
+ \fn template <class T> bool operator==(const QPointer<T> &p, const T *o)
\relates QPointer
Equality operator. Returns \c true if \a o and the guarded
@@ -212,7 +212,7 @@
*/
/*!
- \fn bool operator==(T *o, const QPointer<T> &p)
+ \fn template <class T> bool operator==(T *o, const QPointer<T> &p)
\relates QPointer
Equality operator. Returns \c true if \a o and the guarded
@@ -221,7 +221,7 @@
*/
/*!
- \fn bool operator==(const QPointer<T> &p, T *o)
+ \fn template <class T> bool operator==(const QPointer<T> &p, T *o)
\relates QPointer
Equality operator. Returns \c true if \a o and the guarded
@@ -230,7 +230,7 @@
*/
/*!
- \fn bool operator==(const QPointer<T> &p1, const QPointer<T> &p2)
+ \fn template <class T> bool operator==(const QPointer<T> &p1, const QPointer<T> &p2)
\relates QPointer
Equality operator. Returns \c true if the guarded pointers \a p1 and \a p2
@@ -241,7 +241,7 @@
/*!
- \fn bool operator!=(const T *o, const QPointer<T> &p)
+ \fn template <class T> bool operator!=(const T *o, const QPointer<T> &p)
\relates QPointer
Inequality operator. Returns \c true if \a o and the guarded
@@ -249,7 +249,7 @@
returns \c false.
*/
/*!
- \fn bool operator!=(const QPointer<T> &p, const T *o)
+ \fn template <class T> bool operator!=(const QPointer<T> &p, const T *o)
\relates QPointer
Inequality operator. Returns \c true if \a o and the guarded
@@ -257,7 +257,7 @@
returns \c false.
*/
/*!
- \fn bool operator!=(T *o, const QPointer<T> &p)
+ \fn template <class T> bool operator!=(T *o, const QPointer<T> &p)
\relates QPointer
Inequality operator. Returns \c true if \a o and the guarded
@@ -265,7 +265,7 @@
returns \c false.
*/
/*!
- \fn bool operator!=(const QPointer<T> &p, T *o)
+ \fn template <class T> bool operator!=(const QPointer<T> &p, T *o)
\relates QPointer
Inequality operator. Returns \c true if \a o and the guarded
@@ -273,7 +273,7 @@
returns \c false.
*/
/*!
- \fn bool operator!=(const QPointer<T> &p1, const QPointer<T> &p2)
+ \fn template <class T> bool operator!=(const QPointer<T> &p1, const QPointer<T> &p2)
\relates QPointer
Inequality operator. Returns \c true if the guarded pointers \a p1 and
@@ -281,7 +281,7 @@
returns \c false.
*/
/*!
- \fn QPointer<T> qPointerFromVariant(const QVariant &variant)
+ \fn template <typename T> QPointer<T> qPointerFromVariant(const QVariant &variant)
\internal
diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp
index c8ba13c90c..c952655cb8 100644
--- a/src/corelib/kernel/qsharedmemory.cpp
+++ b/src/corelib/kernel/qsharedmemory.cpp
@@ -67,9 +67,11 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key,
QString result = prefix;
- QString part1 = key;
- part1.replace(QRegExp(QLatin1String("[^A-Za-z]")), QString());
- result.append(part1);
+ for (QChar ch : key) {
+ if ((ch >= QLatin1Char('a') && ch <= QLatin1Char('z')) ||
+ (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z')))
+ result += ch;
+ }
QByteArray hex = QCryptographicHash::hash(key.toUtf8(), QCryptographicHash::Sha1).toHex();
result.append(QLatin1String(hex));
diff --git a/src/corelib/kernel/qsharedmemory.h b/src/corelib/kernel/qsharedmemory.h
index 0d4edef23d..67cf52ac17 100644
--- a/src/corelib/kernel/qsharedmemory.h
+++ b/src/corelib/kernel/qsharedmemory.h
@@ -74,8 +74,8 @@ public:
UnknownError
};
- QSharedMemory(QObject *parent = Q_NULLPTR);
- QSharedMemory(const QString &key, QObject *parent = Q_NULLPTR);
+ QSharedMemory(QObject *parent = nullptr);
+ QSharedMemory(const QString &key, QObject *parent = nullptr);
~QSharedMemory();
void setKey(const QString &key);
diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp
index 2268cb83bb..6ff8268978 100644
--- a/src/corelib/kernel/qsocketnotifier.cpp
+++ b/src/corelib/kernel/qsocketnotifier.cpp
@@ -149,7 +149,7 @@ QSocketNotifier::QSocketNotifier(qintptr socket, Type type, QObject *parent)
if (socket < 0)
qWarning("QSocketNotifier: Invalid socket specified");
- else if (!d->threadData->eventDispatcher.load())
+ else if (!d->threadData->hasEventDispatcher())
qWarning("QSocketNotifier: Can only be used with threads started with QThread");
else
d->threadData->eventDispatcher.load()->registerSocketNotifier(this);
@@ -234,7 +234,7 @@ void QSocketNotifier::setEnabled(bool enable)
return;
d->snenabled = enable;
- if (!d->threadData->eventDispatcher.load()) // perhaps application/thread is shutting down
+ if (!d->threadData->hasEventDispatcher()) // perhaps application/thread is shutting down
return;
if (Q_UNLIKELY(thread() != QThread::currentThread())) {
qWarning("QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread");
diff --git a/src/corelib/kernel/qsocketnotifier.h b/src/corelib/kernel/qsocketnotifier.h
index 92cdf5be95..38e5f27247 100644
--- a/src/corelib/kernel/qsocketnotifier.h
+++ b/src/corelib/kernel/qsocketnotifier.h
@@ -53,7 +53,7 @@ class Q_CORE_EXPORT QSocketNotifier : public QObject
public:
enum Type { Read, Write, Exception };
- QSocketNotifier(qintptr socket, Type, QObject *parent = Q_NULLPTR);
+ QSocketNotifier(qintptr socket, Type, QObject *parent = nullptr);
~QSocketNotifier();
qintptr socket() const;
@@ -68,7 +68,7 @@ Q_SIGNALS:
void activated(int socket, QPrivateSignal);
protected:
- bool event(QEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *) override;
private:
Q_DISABLE_COPY(QSocketNotifier)
diff --git a/src/corelib/kernel/qsystemerror_p.h b/src/corelib/kernel/qsystemerror_p.h
index 1d8c253f53..abc2f1efc1 100644
--- a/src/corelib/kernel/qsystemerror_p.h
+++ b/src/corelib/kernel/qsystemerror_p.h
@@ -56,7 +56,7 @@
QT_BEGIN_NAMESPACE
-class Q_CORE_EXPORT QSystemError
+class QSystemError
{
public:
enum ErrorScope
@@ -66,51 +66,27 @@ public:
NativeError
};
- inline QSystemError(int error, ErrorScope scope);
- inline QSystemError();
+ Q_DECL_CONSTEXPR explicit QSystemError(int error, ErrorScope scope)
+ : errorCode(error), errorScope(scope)
+ {
+ }
+ Q_DECL_CONSTEXPR QSystemError() = default;
- inline QString toString() const;
- inline ErrorScope scope() const;
- inline int error() const;
+ QString toString() const { return string(errorScope, errorCode); }
+ Q_DECL_CONSTEXPR ErrorScope scope() const { return errorScope; }
+ Q_DECL_CONSTEXPR int error() const { return errorCode; }
- static QString string(ErrorScope errorScope, int errorCode);
- static QString stdString(int errorCode = -1);
+ static Q_CORE_EXPORT QString string(ErrorScope errorScope, int errorCode);
+ static Q_CORE_EXPORT QString stdString(int errorCode = -1);
#ifdef Q_OS_WIN
- static QString windowsString(int errorCode = -1);
+ static Q_CORE_EXPORT QString windowsString(int errorCode = -1);
#endif
//data members
- int errorCode;
- ErrorScope errorScope;
+ int errorCode = 0;
+ ErrorScope errorScope = NoError;
};
-QSystemError::QSystemError(int error, QSystemError::ErrorScope scope)
-: errorCode(error), errorScope(scope)
-{
-
-}
-
-QSystemError::QSystemError()
-: errorCode(0), errorScope(NoError)
-{
-
-}
-
-QString QSystemError::toString() const
-{
- return string(errorScope, errorCode);
-}
-
-QSystemError::ErrorScope QSystemError::scope() const
-{
- return errorScope;
-}
-
-int QSystemError::error() const
-{
- return errorCode;
-}
-
QT_END_NAMESPACE
#endif // QSYSTEMERROR_P_H
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp
index 55f75ab17e..c3504943c4 100644
--- a/src/corelib/kernel/qtimer.cpp
+++ b/src/corelib/kernel/qtimer.cpp
@@ -108,7 +108,7 @@ QT_BEGIN_NAMESPACE
in many real-world situations.
The accuracy also depends on the \l{Qt::TimerType}{timer type}. For
- Qt::PreciseTimer, QTimer will try to keep the accurance at 1 millisecond.
+ Qt::PreciseTimer, QTimer will try to keep the accuracy at 1 millisecond.
Precise timers will also never time out earlier than expected.
For Qt::CoarseTimer and Qt::VeryCoarseTimer types, QTimer may wake up
@@ -271,7 +271,7 @@ public:
Q_SIGNALS:
void timeout();
protected:
- void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE;
+ void timerEvent(QTimerEvent *) override;
};
QSingleShotTimer::QSingleShotTimer(int msec, Qt::TimerType timerType, const QObject *r, const char *member)
@@ -410,7 +410,7 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
}
}
-/*!\fn void QTimer::singleShot(int msec, const QObject *receiver, PointerToMemberFunction method)
+/*! \fn template<typename PointerToMemberFunction> void QTimer::singleShot(int msec, const QObject *receiver, PointerToMemberFunction method)
\since 5.4
@@ -432,7 +432,7 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
\sa start()
*/
-/*!\fn void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, PointerToMemberFunction method)
+/*! \fn template<typename PointerToMemberFunction> void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, PointerToMemberFunction method)
\since 5.4
@@ -455,7 +455,7 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
\sa start()
*/
-/*!\fn void QTimer::singleShot(int msec, Functor functor)
+/*! \fn template<typename Functor> void QTimer::singleShot(int msec, Functor functor)
\since 5.4
@@ -472,7 +472,7 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
\sa start()
*/
-/*!\fn void QTimer::singleShot(int msec, Qt::TimerType timerType, Functor functor)
+/*! \fn template<typename Functor> void QTimer::singleShot(int msec, Qt::TimerType timerType, Functor functor)
\since 5.4
@@ -490,7 +490,7 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
\sa start()
*/
-/*!\fn void QTimer::singleShot(int msec, const QObject *context, Functor functor)
+/*! \fn template<typename Functor> void QTimer::singleShot(int msec, const QObject *context, Functor functor)
\since 5.4
@@ -511,7 +511,7 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
\sa start()
*/
-/*!\fn void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *context, Functor functor)
+/*! \fn template<typename Functor> void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *context, Functor functor)
\since 5.4
diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h
index 44ae04f38d..e6db586aa0 100644
--- a/src/corelib/kernel/qtimer.h
+++ b/src/corelib/kernel/qtimer.h
@@ -63,7 +63,7 @@ class Q_CORE_EXPORT QTimer : public QObject
Q_PROPERTY(Qt::TimerType timerType READ timerType WRITE setTimerType)
Q_PROPERTY(bool active READ isActive)
public:
- explicit QTimer(QObject *parent = Q_NULLPTR);
+ explicit QTimer(QObject *parent = nullptr);
~QTimer();
inline bool isActive() const { return id >= 0; }
@@ -83,7 +83,7 @@ public:
static void singleShot(int msec, const QObject *receiver, const char *member);
static void singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, const char *member);
-#ifdef Q_QDOC
+#ifdef Q_CLANG_QDOC
template<typename PointerToMemberFunction>
static void singleShot(int msec, const QObject *receiver, PointerToMemberFunction method);
template<typename PointerToMemberFunction>
@@ -197,7 +197,7 @@ public:
#endif
protected:
- void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE;
+ void timerEvent(QTimerEvent *) override;
private:
Q_DISABLE_COPY(QTimer)
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 2232e24a25..c868f6d266 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -1064,7 +1064,7 @@ searchDependencies:
return QString();
}
-/*!
+/*
Empties this translator of all contents.
This function works with stripped translator files.
diff --git a/src/corelib/kernel/qtranslator.h b/src/corelib/kernel/qtranslator.h
index 97be16bc90..e7c39191e7 100644
--- a/src/corelib/kernel/qtranslator.h
+++ b/src/corelib/kernel/qtranslator.h
@@ -55,11 +55,11 @@ class Q_CORE_EXPORT QTranslator : public QObject
{
Q_OBJECT
public:
- explicit QTranslator(QObject *parent = Q_NULLPTR);
+ explicit QTranslator(QObject *parent = nullptr);
~QTranslator();
virtual QString translate(const char *context, const char *sourceText,
- const char *disambiguation = Q_NULLPTR, int n = -1) const;
+ const char *disambiguation = nullptr, int n = -1) const;
virtual bool isEmpty() const;
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 29429b5e55..96299b9eaf 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -256,6 +256,10 @@ static qreal qConvertToRealNumber(const QVariant::Private *d, bool *ok)
case QMetaType::UShort:
case QMetaType::ULong:
return qreal(qMetaTypeUNumber(d));
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QJsonValue:
+ return v_cast<QJsonValue>(d)->toDouble();
+#endif
default:
// includes enum conversion as well as invalid types
return qreal(qConvertToNumber(d, ok));
@@ -440,10 +444,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
*str = v_cast<QDate>(d)->toString(Qt::ISODate);
break;
case QVariant::Time:
- *str = v_cast<QTime>(d)->toString(Qt::ISODate);
+ *str = v_cast<QTime>(d)->toString(Qt::ISODateWithMs);
break;
case QVariant::DateTime:
- *str = v_cast<QDateTime>(d)->toString(Qt::ISODate);
+ *str = v_cast<QDateTime>(d)->toString(Qt::ISODateWithMs);
break;
#endif
case QVariant::Bool:
@@ -3776,7 +3780,7 @@ void* QVariant::data()
\warning Null variants is not a single state and two null variants may easily
return \c false on the == operator if they do not contain similar null values.
- \sa QVariant(Type), convert(int)
+ \sa convert(int)
*/
bool QVariant::isNull() const
{
@@ -3820,7 +3824,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
#endif
-/*! \fn void QVariant::setValue(const T &value)
+/*! \fn template<typename T> void QVariant::setValue(const T &value)
Stores a copy of \a value. If \c{T} is a type that QVariant
doesn't support, QMetaType is used to store the value. A compile
@@ -3833,7 +3837,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
\sa value(), fromValue(), canConvert()
*/
-/*! \fn T QVariant::value() const
+/*! \fn template<typename T> T QVariant::value() const
Returns the stored value converted to the template type \c{T}.
Call canConvert() to find out whether a type can be converted.
@@ -3877,7 +3881,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
\sa convert()
*/
-/*! \fn static QVariant QVariant::fromValue(const T &value)
+/*! \fn template<typename T> static QVariant QVariant::fromValue(const T &value)
Returns a QVariant containing a copy of \a value. Behaves
exactly like setValue() otherwise.
@@ -3892,8 +3896,21 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
\sa setValue(), value()
*/
+/*! \fn static inline QVariant fromStdVariant(const std::variant<T, Types...> &value)
+ \since 5.11
+
+ Returns a QVariant with the type and value of the active variant of \a value. If
+ the active type is std::monostate a default QVariant is returned.
+
+ \note With this method you do not need to register the variant as a Qt metatype,
+ since the std::variant is resolved before being stored. The component types
+ should be registered however.
+
+ \sa fromValue()
+*/
+
/*!
- \fn QVariant qVariantFromValue(const T &value)
+ \fn template<typename T> QVariant qVariantFromValue(const T &value)
\relates QVariant
\obsolete
@@ -3914,7 +3931,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
\sa QVariant::fromValue()
*/
-/*! \fn void qVariantSetValue(QVariant &variant, const T &value)
+/*! \fn template<typename T> void qVariantSetValue(QVariant &variant, const T &value)
\relates QVariant
\obsolete
@@ -3931,7 +3948,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
*/
/*!
- \fn T qvariant_cast(const QVariant &value)
+ \fn template<typename T> T qvariant_cast(const QVariant &value)
\relates QVariant
Returns the given \a value converted to the template type \c{T}.
@@ -3941,7 +3958,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
\sa QVariant::value()
*/
-/*! \fn T qVariantValue(const QVariant &value)
+/*! \fn template<typename T> T qVariantValue(const QVariant &value)
\relates QVariant
\obsolete
@@ -3999,6 +4016,41 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
\typedef QVariant::DataPtr
\internal
*/
+/*! \typedef QVariant::f_construct
+ \internal
+*/
+
+/*! \typedef QVariant::f_clear
+ \internal
+*/
+
+/*! \typedef QVariant::f_null
+ \internal
+*/
+
+/*! \typedef QVariant::f_load
+ \internal
+*/
+
+/*! \typedef QVariant::f_save
+ \internal
+*/
+
+/*! \typedef QVariant::f_compare
+ \internal
+*/
+
+/*! \typedef QVariant::f_convert
+ \internal
+*/
+
+/*! \typedef QVariant::f_canConvert
+ \internal
+*/
+
+/*! \typedef QVariant::f_debugStream
+ \internal
+*/
/*!
\fn DataPtr &QVariant::data_ptr()
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index a2c5711993..fe1ef1bdfc 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -53,6 +53,10 @@
#include <QtCore/qbytearraylist.h>
#endif
+#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L
+#include <variant>
+#endif
+
QT_BEGIN_NAMESPACE
@@ -284,14 +288,14 @@ class Q_CORE_EXPORT QVariant
void detach();
inline bool isDetached() const;
- int toInt(bool *ok = Q_NULLPTR) const;
- uint toUInt(bool *ok = Q_NULLPTR) const;
- qlonglong toLongLong(bool *ok = Q_NULLPTR) const;
- qulonglong toULongLong(bool *ok = Q_NULLPTR) const;
+ int toInt(bool *ok = nullptr) const;
+ uint toUInt(bool *ok = nullptr) const;
+ qlonglong toLongLong(bool *ok = nullptr) const;
+ qulonglong toULongLong(bool *ok = nullptr) const;
bool toBool() const;
- double toDouble(bool *ok = Q_NULLPTR) const;
- float toFloat(bool *ok = Q_NULLPTR) const;
- qreal toReal(bool *ok = Q_NULLPTR) const;
+ double toDouble(bool *ok = nullptr) const;
+ float toFloat(bool *ok = nullptr) const;
+ qreal toReal(bool *ok = nullptr) const;
QByteArray toByteArray() const;
QBitArray toBitArray() const;
QString toString() const;
@@ -355,12 +359,21 @@ class Q_CORE_EXPORT QVariant
static inline QVariant fromValue(const T &value)
{ return qVariantFromValue(value); }
+#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L
+ template<typename... Types>
+ static inline QVariant fromStdVariant(const std::variant<Types...> &value)
+ {
+ if (value.valueless_by_exception())
+ return QVariant();
+ return std::visit([](const auto &arg) { return fromValue(arg); }, value);
+ }
+#endif
+
template<typename T>
bool canConvert() const
{ return canConvert(qMetaTypeId<T>()); }
public:
-#ifndef Q_QDOC
struct PrivateShared
{
inline PrivateShared(void *v) : ptr(v), ref(1) { }
@@ -370,7 +383,7 @@ class Q_CORE_EXPORT QVariant
struct Private
{
inline Private() Q_DECL_NOTHROW : type(Invalid), is_shared(false), is_null(true)
- { data.ptr = Q_NULLPTR; }
+ { data.ptr = nullptr; }
// Internal constructor for initialized variants.
explicit inline Private(uint variantType) Q_DECL_NOTHROW
@@ -431,7 +444,6 @@ class Q_CORE_EXPORT QVariant
f_canConvert canConvert;
f_debugStream debugStream;
};
-#endif
inline bool operator==(const QVariant &v) const
{ return cmp(v); }
@@ -505,6 +517,11 @@ inline QVariant qVariantFromValue(const T &t)
template <>
inline QVariant qVariantFromValue(const QVariant &t) { return t; }
+#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L
+template <>
+inline QVariant qVariantFromValue(const std::monostate &) { return QVariant(); }
+#endif
+
template <typename T>
inline void qVariantSetValue(QVariant &v, const T &t)
{
diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h
index 75c269d710..b22b7c231e 100644
--- a/src/corelib/kernel/qvariant_p.h
+++ b/src/corelib/kernel/qvariant_p.h
@@ -278,11 +278,11 @@ class QVariantIsNull
Q_STATIC_ASSERT(!HasIsNullMethod<SelfTest2>::Value);
struct SelfTest3 : public SelfTest1 {};
Q_STATIC_ASSERT(HasIsNullMethod<SelfTest3>::Value);
- struct SelfTestFinal1 Q_DECL_FINAL { bool isNull() const; };
+ struct SelfTestFinal1 final { bool isNull() const; };
Q_STATIC_ASSERT(HasIsNullMethod<SelfTestFinal1>::Value);
- struct SelfTestFinal2 Q_DECL_FINAL {};
+ struct SelfTestFinal2 final {};
Q_STATIC_ASSERT(!HasIsNullMethod<SelfTestFinal2>::Value);
- struct SelfTestFinal3 Q_DECL_FINAL : public SelfTest1 {};
+ struct SelfTestFinal3 final : public SelfTest1 {};
Q_STATIC_ASSERT(HasIsNullMethod<SelfTestFinal3>::Value);
template<typename T, bool HasIsNull = HasIsNullMethod<T>::Value>
diff --git a/src/corelib/kernel/qwineventnotifier.h b/src/corelib/kernel/qwineventnotifier.h
index f29f325d13..624e77e638 100644
--- a/src/corelib/kernel/qwineventnotifier.h
+++ b/src/corelib/kernel/qwineventnotifier.h
@@ -54,8 +54,8 @@ class Q_CORE_EXPORT QWinEventNotifier : public QObject
typedef Qt::HANDLE HANDLE;
public:
- explicit QWinEventNotifier(QObject *parent = Q_NULLPTR);
- explicit QWinEventNotifier(HANDLE hEvent, QObject *parent = Q_NULLPTR);
+ explicit QWinEventNotifier(QObject *parent = nullptr);
+ explicit QWinEventNotifier(HANDLE hEvent, QObject *parent = nullptr);
~QWinEventNotifier();
void setHandle(HANDLE hEvent);