summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qcore_mac_objc.mm2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp34
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib.cpp5
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix.cpp2
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp10
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h34
-rw-r--r--src/corelib/kernel/qjni_p.h2
-rw-r--r--src/corelib/kernel/qmetaobject.cpp20
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder_p.h2
-rw-r--r--src/corelib/kernel/qmetatype.cpp623
-rw-r--r--src/corelib/kernel/qmetatype.h10
-rw-r--r--src/corelib/kernel/qmimedata.cpp5
-rw-r--r--src/corelib/kernel/qobject.cpp54
-rw-r--r--src/corelib/kernel/qobject.h8
-rw-r--r--src/corelib/kernel/qobject_p.h6
-rw-r--r--src/corelib/kernel/qobjectdefs_impl.h2
-rw-r--r--src/corelib/kernel/qppsobject_p.h2
-rw-r--r--src/corelib/kernel/qsystemerror.cpp5
-rw-r--r--src/corelib/kernel/qtranslator.cpp33
-rw-r--r--src/corelib/kernel/qvariant.cpp4
-rw-r--r--src/corelib/kernel/qvariant.h4
21 files changed, 328 insertions, 539 deletions
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm
index 4550891e2a..6687eb88a5 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac_objc.mm
@@ -501,7 +501,7 @@ void qt_apple_check_os_version()
if (!applicationName)
applicationName = NSProcessInfo.processInfo.processName;
- fprintf(stderr, "Sorry, \"%s\" can not be run on this version of %s. "
+ fprintf(stderr, "Sorry, \"%s\" cannot be run on this version of %s. "
"Qt requires %s %ld.%ld.%ld or later, you have %s %ld.%ld.%ld.\n",
applicationName.UTF8String, os,
os, long(required.majorVersion), long(required.minorVersion), long(required.patchVersion),
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 6d7985c91b..2250f91dc3 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -1265,7 +1265,11 @@ bool QCoreApplication::closingDown()
\l{QCoreApplication::sendPostedEvents()}{sendPostedEvents()} from
within that local loop.
- Calling this function processes events only for the calling thread.
+ Calling this function processes events only for the calling thread,
+ and returns after all available events have been processed. Available
+ events are events queued before the function call. This means that
+ events that are posted while the function runs will be queued until
+ a later round of event processing.
\threadsafe
@@ -1282,7 +1286,7 @@ void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags)
/*!
\overload processEvents()
- Processes pending events for the calling thread for \a maxtime
+ Processes pending events for the calling thread for \a ms
milliseconds or until there are no more events to process,
whichever is shorter.
@@ -1291,11 +1295,14 @@ void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags)
Calling this function processes events only for the calling thread.
+ \note Unlike the \l{QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags)}{processEvents()}
+ overload, this function also processes events that are posted while the function runs.
+
\threadsafe
\sa exec(), QTimer, QEventLoop::processEvents()
*/
-void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags, int maxtime)
+void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags, int ms)
{
// ### Qt 6: consider splitting this method into a public and a private
// one, so that a user-invoked processEvents can be detected
@@ -1306,7 +1313,7 @@ void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags, int m
QElapsedTimer start;
start.start();
while (data->eventDispatcher.load()->processEvents(flags & ~QEventLoop::WaitForMoreEvents)) {
- if (start.elapsed() > maxtime)
+ if (start.elapsed() > ms)
break;
}
}
@@ -1629,14 +1636,15 @@ bool QCoreApplication::compressEvent(QEvent *event, QObject *receiver, QPostEven
/*!
Immediately dispatches all events which have been previously queued
- with QCoreApplication::postEvent() and which are for the object \a receiver
- and have the event type \a event_type.
+ with QCoreApplication::postEvent() and which are for the object \a
+ receiver and have the event type \a event_type.
Events from the window system are \e not dispatched by this
function, but by processEvents().
- If \a receiver is null, the events of \a event_type are sent for all
- objects. If \a event_type is 0, all the events are sent for \a receiver.
+ If \a receiver is \nullptr, the events of \a event_type are sent for
+ all objects. If \a event_type is 0, all the events are sent for
+ \a receiver.
\note This method must be called from the thread in which its QObject
parameter, \a receiver, lives.
@@ -1817,10 +1825,10 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type
call it, be aware that killing events may cause \a receiver to
break one or more invariants.
- If \a receiver is null, the events of \a eventType are removed for
- all objects. If \a eventType is 0, all the events are removed for
- \a receiver. You should never call this function with \a eventType
- of 0.
+ If \a receiver is \nullptr, the events of \a eventType are removed
+ for all objects. If \a eventType is 0, all the events are removed
+ for \a receiver. You should never call this function with \a
+ eventType of 0.
\threadsafe
*/
@@ -2133,7 +2141,7 @@ static void replacePercentN(QString *result, int n)
\a disambiguation is an identifying string, for when the same \a
sourceText is used in different roles within the same context. By
- default, it is null.
+ default, it is \nullptr.
See the \l QTranslator and \l QObject::tr() documentation for
more information about contexts, disambiguations and comments.
diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp
index 45c6e29e4b..34c2dde6a8 100644
--- a/src/corelib/kernel/qeventdispatcher_glib.cpp
+++ b/src/corelib/kernel/qeventdispatcher_glib.cpp
@@ -86,9 +86,10 @@ static gboolean socketNotifierSourceCheck(GSource *source)
p->pollfd.fd, t[int(p->socketNotifier->type())]);
// ### note, modifies src->pollfds!
p->socketNotifier->setEnabled(false);
+ i--;
+ } else {
+ pending = pending || ((p->pollfd.revents & p->pollfd.events) != 0);
}
-
- pending = ((p->pollfd.revents & p->pollfd.events) != 0);
}
return pending;
diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp
index 535f86fefe..df0cac0239 100644
--- a/src/corelib/kernel/qeventdispatcher_unix.cpp
+++ b/src/corelib/kernel/qeventdispatcher_unix.cpp
@@ -225,7 +225,7 @@ int QThreadPipe::check(const pollfd &pfd)
QEventDispatcherUNIXPrivate::QEventDispatcherUNIXPrivate()
{
if (Q_UNLIKELY(threadPipe.init() == false))
- qFatal("QEventDispatcherUNIXPrivate(): Can not continue without a thread pipe");
+ qFatal("QEventDispatcherUNIXPrivate(): Cannot continue without a thread pipe");
}
QEventDispatcherUNIXPrivate::~QEventDispatcherUNIXPrivate()
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index b3b6b1be20..685d765adb 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -992,8 +992,14 @@ int QEventDispatcherWin32::remainingTime(int timerId)
quint64 currentTime = qt_msectime();
for (const WinTimerInfo *t : qAsConst(d->timerVec)) {
- if (t && t->timerId == timerId) // timer found, return time to wait
- return t->timeout > currentTime ? t->timeout - currentTime : 0;
+ if (t && t->timerId == timerId) {
+ // timer found, return time to wait
+
+ if (d->internalHwnd)
+ return t->timeout > currentTime ? t->timeout - currentTime : 0;
+ else
+ return t->interval;
+ }
}
#ifndef QT_NO_DEBUG
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index 3bb618153b..dbad2a5450 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -80,31 +80,31 @@ public:
explicit QEventDispatcherWin32(QObject *parent = 0);
~QEventDispatcherWin32();
- bool QT_ENSURE_STACK_ALIGNED_FOR_SSE processEvents(QEventLoop::ProcessEventsFlags flags);
- bool hasPendingEvents();
+ bool QT_ENSURE_STACK_ALIGNED_FOR_SSE processEvents(QEventLoop::ProcessEventsFlags flags) override;
+ bool hasPendingEvents() override;
- void registerSocketNotifier(QSocketNotifier *notifier);
- void unregisterSocketNotifier(QSocketNotifier *notifier);
+ void registerSocketNotifier(QSocketNotifier *notifier) override;
+ void unregisterSocketNotifier(QSocketNotifier *notifier) override;
- void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object);
- bool unregisterTimer(int timerId);
- bool unregisterTimers(QObject *object);
- QList<TimerInfo> registeredTimers(QObject *object) const;
+ void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object) override;
+ bool unregisterTimer(int timerId) override;
+ bool unregisterTimers(QObject *object) override;
+ QList<TimerInfo> registeredTimers(QObject *object) const override;
- bool registerEventNotifier(QWinEventNotifier *notifier);
- void unregisterEventNotifier(QWinEventNotifier *notifier);
+ bool registerEventNotifier(QWinEventNotifier *notifier) override;
+ void unregisterEventNotifier(QWinEventNotifier *notifier) override;
void activateEventNotifiers();
- int remainingTime(int timerId);
+ int remainingTime(int timerId) override;
- void wakeUp();
- void interrupt();
- void flush();
+ void wakeUp() override;
+ void interrupt() override;
+ void flush() override;
- void startingUp();
- void closingDown();
+ void startingUp() override;
+ void closingDown() override;
- bool event(QEvent *e);
+ bool event(QEvent *e) override;
HWND internalHwnd();
diff --git a/src/corelib/kernel/qjni_p.h b/src/corelib/kernel/qjni_p.h
index 52abd51dc1..ec8525e6e1 100644
--- a/src/corelib/kernel/qjni_p.h
+++ b/src/corelib/kernel/qjni_p.h
@@ -76,7 +76,7 @@ public:
private:
friend class QAndroidJniEnvironment;
- Q_DISABLE_COPY(QJNIEnvironmentPrivate)
+ Q_DISABLE_COPY_MOVE(QJNIEnvironmentPrivate)
JNIEnv *jniEnv;
};
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index b8b5c0de46..2ff8b32e0a 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -216,8 +216,8 @@ private:
Constructs a new instance of this class. You can pass up to ten arguments
(\a val0, \a val1, \a val2, \a val3, \a val4, \a val5, \a val6, \a val7,
- \a val8, and \a val9) to the constructor. Returns the new object, or 0 if
- no suitable constructor is available.
+ \a val8, and \a val9) to the constructor. Returns the new object, or
+ \nullptr if no suitable constructor is available.
Note that only constructors that are declared with the Q_INVOKABLE
modifier are made available through the meta-object system.
@@ -321,8 +321,8 @@ const char *QMetaObject::className() const
/*!
\fn QMetaObject *QMetaObject::superClass() const
- Returns the meta-object of the superclass, or 0 if there is no
- such object.
+ Returns the meta-object of the superclass, or \nullptr if there is
+ no such object.
\sa className()
*/
@@ -2257,9 +2257,9 @@ bool QMetaMethod::invoke(QObject *object,
return false;
// check connection type
- QThread *currentThread = QThread::currentThread();
- QThread *objectThread = object->thread();
if (connectionType == Qt::AutoConnection) {
+ QThread *currentThread = QThread::currentThread();
+ QThread *objectThread = object->thread();
connectionType = currentThread == objectThread
? Qt::DirectConnection
: Qt::QueuedConnection;
@@ -2342,6 +2342,8 @@ bool QMetaMethod::invoke(QObject *object,
0, -1, nargs, types, args));
} else { // blocking queued connection
#if QT_CONFIG(thread)
+ QThread *currentThread = QThread::currentThread();
+ QThread *objectThread = object->thread();
if (currentThread == objectThread) {
qWarning("QMetaMethod::invoke: Dead lock detected in "
"BlockingQueuedConnection: Receiver is %s(%p)",
@@ -2613,7 +2615,7 @@ int QMetaEnum::keyCount() const
}
/*!
- Returns the key with the given \a index, or 0 if no such key exists.
+ Returns the key with the given \a index, or \nullptr if no such key exists.
\sa keyCount(), value(), valueToKey()
*/
@@ -2735,7 +2737,7 @@ int QMetaEnum::keyToValue(const char *key, bool *ok) const
/*!
Returns the string that is used as the name of the given
- enumeration \a value, or 0 if \a value is not defined.
+ enumeration \a value, or \nullptr if \a value is not defined.
For flag types, use valueToKeys().
@@ -3520,7 +3522,7 @@ bool QMetaProperty::isStored(const QObject *object) const
false. e.g., the \c text property is the \c USER editable property
of a QLineEdit.
- If \a object is null, the function returns \c false if the \c
+ If \a object is \nullptr, the function returns \c false if the \c
{Q_PROPERTY()}'s \c USER attribute is false. Otherwise it returns
true.
diff --git a/src/corelib/kernel/qmetaobjectbuilder_p.h b/src/corelib/kernel/qmetaobjectbuilder_p.h
index 115ec835aa..6100835bad 100644
--- a/src/corelib/kernel/qmetaobjectbuilder_p.h
+++ b/src/corelib/kernel/qmetaobjectbuilder_p.h
@@ -184,7 +184,7 @@ public:
#endif
private:
- Q_DISABLE_COPY(QMetaObjectBuilder)
+ Q_DISABLE_COPY_MOVE(QMetaObjectBuilder)
QMetaObjectBuilderPrivate *d;
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 632b86959d..45d0b5df6c 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -290,6 +290,10 @@ struct DefinedTypesFilter {
\value QJsonObject QJsonObject
\value QJsonArray QJsonArray
\value QJsonDocument QJsonDocument
+ \value QCborValue QCborValue
+ \value QCborArray QCborArray
+ \value QCborMap QCborMap
+ \value QCborSimpleType QCborSimpleType
\value QModelIndex QModelIndex
\value QPersistentModelIndex QPersistentModelIndex (since 5.5)
\value QUuid QUuid
@@ -373,6 +377,13 @@ struct DefinedTypesFilter {
*/
/*!
+ \fn int QMetaType::id() const
+ \since 5.13
+
+ Returns id type hold by this QMetatype instance.
+*/
+
+/*!
\fn bool QMetaType::sizeOf() const
\since 5.0
@@ -410,8 +421,8 @@ struct DefinedTypesFilter {
pointer of this type. (given by QVariant::data for example)
If the type is an enumeration, flags() contains QMetaType::IsEnumeration, and this function
- returns the QMetaObject of the enclosing object if the enum was registered as a Q_ENUM or 0
- otherwise
+ returns the QMetaObject of the enclosing object if the enum was registered as a Q_ENUM or
+ \nullptr otherwise
\sa QMetaType::metaObjectForType(), QMetaType::flags()
*/
@@ -421,7 +432,7 @@ struct DefinedTypesFilter {
\since 5.0
Returns a copy of \a copy, assuming it is of the type that this
- QMetaType instance was created for. If \a copy is null, creates
+ QMetaType instance was created for. If \a copy is \nullptr, creates
a default constructed instance.
\sa QMetaType::destroy()
@@ -1374,236 +1385,197 @@ int QMetaType::type(const QT_PREPEND_NAMESPACE(QByteArray) &typeName)
}
#ifndef QT_NO_DATASTREAM
-/*!
- Writes the object pointed to by \a data with the ID \a type to
- the given \a stream. Returns \c true if the object is saved
- successfully; otherwise returns \c false.
- The type must have been registered with qRegisterMetaType() and
- qRegisterMetaTypeStreamOperators() beforehand.
+namespace
+{
- Normally, you should not need to call this function directly.
- Instead, use QVariant's \c operator<<(), which relies on save()
- to stream custom types.
+template<typename T>
+class HasStreamOperator
+{
+ struct Yes { char unused[1]; };
+ struct No { char unused[2]; };
+ Q_STATIC_ASSERT(sizeof(Yes) != sizeof(No));
+
+ template<class C> static decltype(std::declval<QDataStream&>().operator>>(std::declval<C&>()), Yes()) load(int);
+ template<class C> static decltype(operator>>(std::declval<QDataStream&>(), std::declval<C&>()), Yes()) load(int);
+ template<class C> static No load(...);
+ template<class C> static decltype(operator<<(std::declval<QDataStream&>(), std::declval<const C&>()), Yes()) saveFunction(int);
+ template<class C> static decltype(std::declval<QDataStream&>().operator<<(std::declval<const C&>()), Yes()) saveMethod(int);
+ template<class C> static No saveMethod(...);
+ template<class C> static No saveFunction(...);
+ static constexpr bool LoadValue = QtMetaTypePrivate::TypeDefinition<T>::IsAvailable && (sizeof(load<T>(0)) == sizeof(Yes));
+ static constexpr bool SaveValue = QtMetaTypePrivate::TypeDefinition<T>::IsAvailable &&
+ ((sizeof(saveMethod<T>(0)) == sizeof(Yes)) || (sizeof(saveFunction<T>(0)) == sizeof(Yes)));
+public:
+ static constexpr bool Value = LoadValue && SaveValue;
+};
- \sa load(), qRegisterMetaTypeStreamOperators()
-*/
-bool QMetaType::save(QDataStream &stream, int type, const void *data)
+// Quick sanity checks
+Q_STATIC_ASSERT(HasStreamOperator<NS(QJsonDocument)>::Value);
+Q_STATIC_ASSERT(!HasStreamOperator<void*>::Value);
+Q_STATIC_ASSERT(HasStreamOperator<qint8>::Value);
+
+template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted && HasStreamOperator<T>::Value>
+struct FilteredOperatorSwitch
+{
+ static bool load(QDataStream &stream, T *data, int)
+ {
+ stream >> *data;
+ return true;
+ }
+ static bool save(QDataStream &stream, const T *data, int)
+ {
+ stream << *data;
+ return true;
+ }
+};
+template<typename T>
+struct FilteredOperatorSwitch<T, /* IsAcceptedType = */ false>
{
- if (!data || !isRegistered(type))
+ static const QMetaTypeInterface* getMetaTypeInterface(int type)
+ {
+ if (QModulesPrivate::QTypeModuleInfo<T>::IsGui && qMetaTypeGuiHelper)
+ return &qMetaTypeGuiHelper[type - QMetaType::FirstGuiType];
+ else if (QModulesPrivate::QTypeModuleInfo<T>::IsWidget && qMetaTypeWidgetsHelper)
+ return &qMetaTypeWidgetsHelper[type - QMetaType::FirstWidgetsType];
+ return nullptr;
+ }
+ static bool save(QDataStream &stream, const T *data, int type)
+ {
+ if (auto interface = getMetaTypeInterface(type)) {
+ interface->saveOp(stream, data);
+ return true;
+ }
return false;
-
- switch(type) {
- case QMetaType::UnknownType:
- case QMetaType::Void:
- case QMetaType::VoidStar:
- case QMetaType::QObjectStar:
-#if QT_CONFIG(itemmodel)
- case QMetaType::QModelIndex:
- case QMetaType::QPersistentModelIndex:
-#endif
- case QMetaType::QJsonValue:
- case QMetaType::QJsonObject:
- case QMetaType::QJsonArray:
- case QMetaType::QJsonDocument:
- case QMetaType::QCborValue:
- case QMetaType::QCborArray:
- case QMetaType::QCborMap:
+ }
+ static bool load(QDataStream &stream, T *data, int type)
+ {
+ if (auto interface = getMetaTypeInterface(type)) {
+ interface->loadOp(stream, data);
+ return true;
+ }
return false;
- case QMetaType::Nullptr:
- stream << *static_cast<const std::nullptr_t *>(data);
- return true;
- case QMetaType::Long:
- stream << qlonglong(*static_cast<const long *>(data));
- break;
- case QMetaType::Int:
- stream << *static_cast<const int *>(data);
- break;
- case QMetaType::Short:
- stream << *static_cast<const short *>(data);
- break;
- case QMetaType::Char:
+ }
+};
+
+class SaveOperatorSwitch
+{
+public:
+ QDataStream &stream;
+ int m_type;
+
+ template<typename T>
+ bool delegate(const T *data)
+ {
+ return FilteredOperatorSwitch<T>::save(stream, data, m_type);
+ }
+ bool delegate(const char *data)
+ {
// force a char to be signed
- stream << *static_cast<const signed char *>(data);
- break;
- case QMetaType::ULong:
- stream << qulonglong(*static_cast<const ulong *>(data));
- break;
- case QMetaType::UInt:
- stream << *static_cast<const uint *>(data);
- break;
- case QMetaType::LongLong:
- stream << *static_cast<const qlonglong *>(data);
- break;
- case QMetaType::ULongLong:
- stream << *static_cast<const qulonglong *>(data);
- break;
- case QMetaType::UShort:
- stream << *static_cast<const ushort *>(data);
- break;
- case QMetaType::SChar:
- stream << *static_cast<const signed char *>(data);
- break;
- case QMetaType::UChar:
- stream << *static_cast<const uchar *>(data);
- break;
- case QMetaType::Bool:
- stream << qint8(*static_cast<const bool *>(data));
- break;
- case QMetaType::Float:
- stream << *static_cast<const float *>(data);
- break;
- case QMetaType::Double:
- stream << *static_cast<const double *>(data);
- break;
- case QMetaType::QChar:
- stream << *static_cast<const NS(QChar) *>(data);
- break;
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QVariantMap:
- stream << *static_cast<const NS(QVariantMap)*>(data);
- break;
- case QMetaType::QVariantHash:
- stream << *static_cast<const NS(QVariantHash)*>(data);
- break;
- case QMetaType::QVariantList:
- stream << *static_cast<const NS(QVariantList)*>(data);
- break;
- case QMetaType::QVariant:
- stream << *static_cast<const NS(QVariant)*>(data);
- break;
- case QMetaType::QByteArrayList:
- stream << *static_cast<const NS(QByteArrayList)*>(data);
- break;
-#endif
- case QMetaType::QByteArray:
- stream << *static_cast<const NS(QByteArray)*>(data);
- break;
- case QMetaType::QString:
- stream << *static_cast<const NS(QString)*>(data);
- break;
- case QMetaType::QStringList:
- stream << *static_cast<const NS(QStringList)*>(data);
- break;
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QBitArray:
- stream << *static_cast<const NS(QBitArray)*>(data);
- break;
-#endif
- case QMetaType::QDate:
- stream << *static_cast<const NS(QDate)*>(data);
- break;
- case QMetaType::QTime:
- stream << *static_cast<const NS(QTime)*>(data);
- break;
- case QMetaType::QDateTime:
- stream << *static_cast<const NS(QDateTime)*>(data);
- break;
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QUrl:
- stream << *static_cast<const NS(QUrl)*>(data);
- break;
-#endif
- case QMetaType::QLocale:
- stream << *static_cast<const NS(QLocale)*>(data);
- break;
-#ifndef QT_NO_GEOM_VARIANT
- case QMetaType::QRect:
- stream << *static_cast<const NS(QRect)*>(data);
- break;
- case QMetaType::QRectF:
- stream << *static_cast<const NS(QRectF)*>(data);
- break;
- case QMetaType::QSize:
- stream << *static_cast<const NS(QSize)*>(data);
- break;
- case QMetaType::QSizeF:
- stream << *static_cast<const NS(QSizeF)*>(data);
- break;
- case QMetaType::QLine:
- stream << *static_cast<const NS(QLine)*>(data);
- break;
- case QMetaType::QLineF:
- stream << *static_cast<const NS(QLineF)*>(data);
- break;
- case QMetaType::QPoint:
- stream << *static_cast<const NS(QPoint)*>(data);
- break;
- case QMetaType::QPointF:
- stream << *static_cast<const NS(QPointF)*>(data);
- break;
-#endif
-#ifndef QT_NO_REGEXP
- case QMetaType::QRegExp:
- stream << *static_cast<const NS(QRegExp)*>(data);
- break;
-#endif
-#if QT_CONFIG(regularexpression)
- case QMetaType::QRegularExpression:
- stream << *static_cast<const NS(QRegularExpression)*>(data);
- break;
-#endif // QT_CONFIG(regularexpression)
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QEasingCurve:
- stream << *static_cast<const NS(QEasingCurve)*>(data);
- break;
- case QMetaType::QCborSimpleType:
- stream << *static_cast<const quint8 *>(data);
- break;
-#endif // QT_BOOTSTRAPPED
- case QMetaType::QFont:
- case QMetaType::QPixmap:
- case QMetaType::QBrush:
- case QMetaType::QColor:
- case QMetaType::QPalette:
- case QMetaType::QImage:
- case QMetaType::QPolygon:
- case QMetaType::QPolygonF:
- case QMetaType::QRegion:
- case QMetaType::QBitmap:
- case QMetaType::QCursor:
- case QMetaType::QKeySequence:
- case QMetaType::QPen:
- case QMetaType::QTextLength:
- case QMetaType::QTextFormat:
- case QMetaType::QMatrix:
- case QMetaType::QTransform:
- case QMetaType::QMatrix4x4:
- case QMetaType::QVector2D:
- case QMetaType::QVector3D:
- case QMetaType::QVector4D:
- case QMetaType::QQuaternion:
- case QMetaType::QIcon:
- if (!qMetaTypeGuiHelper)
- return false;
- qMetaTypeGuiHelper[type - FirstGuiType].saveOp(stream, data);
- break;
- case QMetaType::QSizePolicy:
- if (!qMetaTypeWidgetsHelper)
- return false;
- qMetaTypeWidgetsHelper[type - FirstWidgetsType].saveOp(stream, data);
- break;
- case QMetaType::QUuid:
- stream << *static_cast<const NS(QUuid)*>(data);
- break;
- default: {
+ stream << qint8(*data);
+ return true;
+ }
+ bool delegate(const long *data)
+ {
+ stream << qlonglong(*data);
+ return true;
+ }
+ bool delegate(const unsigned long *data)
+ {
+ stream << qulonglong(*data);
+ return true;
+ }
+ bool delegate(const QMetaTypeSwitcher::NotBuiltinType *data)
+ {
const QVector<QCustomTypeInfo> * const ct = customTypes();
if (!ct)
return false;
-
- SaveOperator saveOp = 0;
+ QMetaType::SaveOperator saveOp = nullptr;
{
QReadLocker locker(customTypesLock());
- saveOp = ct->at(type - User).saveOp;
+ saveOp = ct->at(m_type - QMetaType::User).saveOp;
}
-
if (!saveOp)
return false;
saveOp(stream, data);
- break; }
+ return true;
}
+ bool delegate(const void*) { return false; }
+ bool delegate(const QMetaTypeSwitcher::UnknownType*) { return false; }
+};
+class LoadOperatorSwitch
+{
+public:
+ QDataStream &stream;
+ int m_type;
- return true;
+ template<typename T>
+ bool delegate(const T *data)
+ {
+ return FilteredOperatorSwitch<T>::load(stream, const_cast<T*>(data), m_type);
+ }
+ bool delegate(const char *data)
+ {
+ // force a char to be signed
+ qint8 c;
+ stream >> c;
+ *const_cast<char*>(data) = c;
+ return true;
+ }
+ bool delegate(const long *data)
+ {
+ qlonglong l;
+ stream >> l;
+ *const_cast<long*>(data) = l;
+ return true;
+ }
+ bool delegate(const unsigned long *data)
+ {
+ qlonglong l;
+ stream >> l;
+ *const_cast<unsigned long*>(data) = l;
+ return true;
+ }
+ bool delegate(const QMetaTypeSwitcher::NotBuiltinType *data)
+ {
+ const QVector<QCustomTypeInfo> * const ct = customTypes();
+ if (!ct)
+ return false;
+ QMetaType::LoadOperator loadOp = nullptr;
+ {
+ QReadLocker locker(customTypesLock());
+ loadOp = ct->at(m_type - QMetaType::User).loadOp;
+ }
+ if (!loadOp)
+ return false;
+ loadOp(stream, const_cast<QMetaTypeSwitcher::NotBuiltinType*>(data));
+ return true;
+ }
+ bool delegate(const void*) { return false; }
+ bool delegate(const QMetaTypeSwitcher::UnknownType*) { return false; }
+};
+} // namespace
+
+/*!
+ Writes the object pointed to by \a data with the ID \a type to
+ the given \a stream. Returns \c true if the object is saved
+ successfully; otherwise returns \c false.
+
+ The type must have been registered with qRegisterMetaType() and
+ qRegisterMetaTypeStreamOperators() beforehand.
+
+ Normally, you should not need to call this function directly.
+ Instead, use QVariant's \c operator<<(), which relies on save()
+ to stream custom types.
+
+ \sa load(), qRegisterMetaTypeStreamOperators()
+*/
+bool QMetaType::save(QDataStream &stream, int type, const void *data)
+{
+ if (!data)
+ return false;
+ SaveOperatorSwitch saveOp{stream, type};
+ return QMetaTypeSwitcher::switcher<bool>(saveOp, type, data);
}
/*!
@@ -1622,225 +1594,10 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
*/
bool QMetaType::load(QDataStream &stream, int type, void *data)
{
- if (!data || !isRegistered(type))
- return false;
-
- switch(type) {
- case QMetaType::UnknownType:
- case QMetaType::Void:
- case QMetaType::VoidStar:
- case QMetaType::QObjectStar:
-#if QT_CONFIG(itemmodel)
- case QMetaType::QModelIndex:
- case QMetaType::QPersistentModelIndex:
-#endif
- case QMetaType::QJsonValue:
- case QMetaType::QJsonObject:
- case QMetaType::QJsonArray:
- case QMetaType::QJsonDocument:
- case QMetaType::QCborValue:
- case QMetaType::QCborArray:
- case QMetaType::QCborMap:
+ if (!data)
return false;
- case QMetaType::Nullptr:
- stream >> *static_cast<std::nullptr_t *>(data);
- return true;
- case QMetaType::Long: {
- qlonglong l;
- stream >> l;
- *static_cast<long *>(data) = long(l);
- break; }
- case QMetaType::Int:
- stream >> *static_cast<int *>(data);
- break;
- case QMetaType::Short:
- stream >> *static_cast<short *>(data);
- break;
- case QMetaType::Char:
- // force a char to be signed
- stream >> *static_cast<signed char *>(data);
- break;
- case QMetaType::ULong: {
- qulonglong ul;
- stream >> ul;
- *static_cast<ulong *>(data) = ulong(ul);
- break; }
- case QMetaType::UInt:
- stream >> *static_cast<uint *>(data);
- break;
- case QMetaType::LongLong:
- stream >> *static_cast<qlonglong *>(data);
- break;
- case QMetaType::ULongLong:
- stream >> *static_cast<qulonglong *>(data);
- break;
- case QMetaType::UShort:
- stream >> *static_cast<ushort *>(data);
- break;
- case QMetaType::SChar:
- stream >> *static_cast<signed char *>(data);
- break;
- case QMetaType::UChar:
- stream >> *static_cast<uchar *>(data);
- break;
- case QMetaType::Bool: {
- qint8 b;
- stream >> b;
- *static_cast<bool *>(data) = b;
- break; }
- case QMetaType::Float:
- stream >> *static_cast<float *>(data);
- break;
- case QMetaType::Double:
- stream >> *static_cast<double *>(data);
- break;
- case QMetaType::QChar:
- stream >> *static_cast< NS(QChar)*>(data);
- break;
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QVariantMap:
- stream >> *static_cast< NS(QVariantMap)*>(data);
- break;
- case QMetaType::QVariantHash:
- stream >> *static_cast< NS(QVariantHash)*>(data);
- break;
- case QMetaType::QVariantList:
- stream >> *static_cast< NS(QVariantList)*>(data);
- break;
- case QMetaType::QVariant:
- stream >> *static_cast< NS(QVariant)*>(data);
- break;
- case QMetaType::QByteArrayList:
- stream >> *static_cast< NS(QByteArrayList)*>(data);
- break;
-#endif
- case QMetaType::QByteArray:
- stream >> *static_cast< NS(QByteArray)*>(data);
- break;
- case QMetaType::QString:
- stream >> *static_cast< NS(QString)*>(data);
- break;
- case QMetaType::QStringList:
- stream >> *static_cast< NS(QStringList)*>(data);
- break;
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QBitArray:
- stream >> *static_cast< NS(QBitArray)*>(data);
- break;
-#endif
- case QMetaType::QDate:
- stream >> *static_cast< NS(QDate)*>(data);
- break;
- case QMetaType::QTime:
- stream >> *static_cast< NS(QTime)*>(data);
- break;
- case QMetaType::QDateTime:
- stream >> *static_cast< NS(QDateTime)*>(data);
- break;
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QUrl:
- stream >> *static_cast< NS(QUrl)*>(data);
- break;
-#endif
- case QMetaType::QLocale:
- stream >> *static_cast< NS(QLocale)*>(data);
- break;
-#ifndef QT_NO_GEOM_VARIANT
- case QMetaType::QRect:
- stream >> *static_cast< NS(QRect)*>(data);
- break;
- case QMetaType::QRectF:
- stream >> *static_cast< NS(QRectF)*>(data);
- break;
- case QMetaType::QSize:
- stream >> *static_cast< NS(QSize)*>(data);
- break;
- case QMetaType::QSizeF:
- stream >> *static_cast< NS(QSizeF)*>(data);
- break;
- case QMetaType::QLine:
- stream >> *static_cast< NS(QLine)*>(data);
- break;
- case QMetaType::QLineF:
- stream >> *static_cast< NS(QLineF)*>(data);
- break;
- case QMetaType::QPoint:
- stream >> *static_cast< NS(QPoint)*>(data);
- break;
- case QMetaType::QPointF:
- stream >> *static_cast< NS(QPointF)*>(data);
- break;
-#endif
-#ifndef QT_NO_REGEXP
- case QMetaType::QRegExp:
- stream >> *static_cast< NS(QRegExp)*>(data);
- break;
-#endif
-#if QT_CONFIG(regularexpression)
- case QMetaType::QRegularExpression:
- stream >> *static_cast< NS(QRegularExpression)*>(data);
- break;
-#endif // QT_CONFIG(regularexpression)
-#ifndef QT_BOOTSTRAPPED
- case QMetaType::QEasingCurve:
- stream >> *static_cast< NS(QEasingCurve)*>(data);
- break;
- case QMetaType::QCborSimpleType:
- stream >> *static_cast<quint8 *>(data);
- break;
-#endif // QT_BOOTSTRAPPED
- case QMetaType::QFont:
- case QMetaType::QPixmap:
- case QMetaType::QBrush:
- case QMetaType::QColor:
- case QMetaType::QPalette:
- case QMetaType::QImage:
- case QMetaType::QPolygon:
- case QMetaType::QPolygonF:
- case QMetaType::QRegion:
- case QMetaType::QBitmap:
- case QMetaType::QCursor:
- case QMetaType::QKeySequence:
- case QMetaType::QPen:
- case QMetaType::QTextLength:
- case QMetaType::QTextFormat:
- case QMetaType::QMatrix:
- case QMetaType::QTransform:
- case QMetaType::QMatrix4x4:
- case QMetaType::QVector2D:
- case QMetaType::QVector3D:
- case QMetaType::QVector4D:
- case QMetaType::QQuaternion:
- case QMetaType::QIcon:
- if (!qMetaTypeGuiHelper)
- return false;
- qMetaTypeGuiHelper[type - FirstGuiType].loadOp(stream, data);
- break;
- case QMetaType::QSizePolicy:
- if (!qMetaTypeWidgetsHelper)
- return false;
- qMetaTypeWidgetsHelper[type - FirstWidgetsType].loadOp(stream, data);
- break;
- case QMetaType::QUuid:
- stream >> *static_cast< NS(QUuid)*>(data);
- break;
- default: {
- const QVector<QCustomTypeInfo> * const ct = customTypes();
- if (!ct)
- return false;
-
- LoadOperator loadOp = 0;
- {
- QReadLocker locker(customTypesLock());
- loadOp = ct->at(type - User).loadOp;
- }
-
- if (!loadOp)
- return false;
- loadOp(stream, data);
- break; }
- }
- return true;
+ LoadOperatorSwitch loadOp{stream, type};
+ return QMetaTypeSwitcher::switcher<bool>(loadOp, type, data);
}
#endif // QT_NO_DATASTREAM
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index ed7feee775..a47fbfe28d 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -570,6 +570,7 @@ public:
inline bool isValid() const;
inline bool isRegistered() const;
+ inline int id() const;
inline int sizeOf() const;
inline TypeFlags flags() const;
inline const QMetaObject *metaObject() const;
@@ -1976,7 +1977,9 @@ 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_CLANG_QDOC
+#ifdef Q_CLANG_QDOC
+class QByteArrayList;
+#else
typedef QList<QByteArray> QByteArrayList;
#endif
@@ -2221,6 +2224,11 @@ inline bool QMetaType::isRegistered() const
return isValid();
}
+inline int QMetaType::id() const
+{
+ return m_typeId;
+}
+
inline void *QMetaType::create(const void *copy) const
{
// ### TODO Qt6 remove the extension
diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp
index c8ad1bc43f..9a98db21d3 100644
--- a/src/corelib/kernel/qmimedata.cpp
+++ b/src/corelib/kernel/qmimedata.cpp
@@ -51,6 +51,7 @@ QT_BEGIN_NAMESPACE
static inline QString textUriListLiteral() { return QStringLiteral("text/uri-list"); }
static inline QString textHtmlLiteral() { return QStringLiteral("text/html"); }
static inline QString textPlainLiteral() { return QStringLiteral("text/plain"); }
+static inline QString textPlainUtf8Literal() { return QStringLiteral("text/plain;charset=utf-8"); }
static inline QString applicationXColorLiteral() { return QStringLiteral("application/x-color"); }
static inline QString applicationXQtImageLiteral() { return QStringLiteral("application/x-qt-image"); }
@@ -399,6 +400,10 @@ bool QMimeData::hasUrls() const
QString QMimeData::text() const
{
Q_D(const QMimeData);
+ QVariant utf8Text = d->retrieveTypedData(textPlainUtf8Literal(), QVariant::String);
+ if (!utf8Text.isNull())
+ return utf8Text.toString();
+
QVariant data = d->retrieveTypedData(textPlainLiteral(), QVariant::String);
return data.toString();
}
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index a791d2e8b3..d03b9fafb1 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1763,7 +1763,7 @@ void QObject::killTimer(int id)
\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.
+ that is called \a name, or \nullptr if there is no such object.
Omitting the \a name argument causes all object names to be matched.
The search is performed recursively, unless \a options specifies the
option FindDirectChildrenOnly.
@@ -1824,12 +1824,15 @@ void QObject::killTimer(int id)
/*!
\fn template<typename T> QList<T> QObject::findChildren(const QRegExp &regExp, Qt::FindChildOptions options) const
\overload findChildren()
+ \obsolete
Returns the children of this object that can be cast to type T
and that have names matching the regular expression \a regExp,
or an empty list if there are no such objects.
The search is performed recursively, unless \a options specifies the
option FindDirectChildrenOnly.
+
+ Use the findChildren overload taking a QRegularExpression instead.
*/
/*!
@@ -2148,7 +2151,8 @@ void QObject::removeEventFilter(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.
+ destroyed, after any instances of QPointer have been notified,
+ and cannot be blocked.
All the objects's children are destroyed immediately after this
signal is emitted.
@@ -2930,8 +2934,8 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho
0 may be used as a wildcard, meaning "any signal", "any receiving
object", or "any slot in the receiving object", respectively.
- The \a sender may never be 0. (You cannot disconnect signals from
- more than one object in a single call.)
+ The \a sender may never be \nullptr. (You cannot disconnect signals
+ from more than one object in a single call.)
If \a signal is 0, it disconnects \a receiver and \a method from
any signal. If not, only the specified signal is disconnected.
@@ -2942,8 +2946,8 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho
If \a method is 0, it disconnects anything that is connected to \a
receiver. If not, only slots named \a method will be disconnected,
- and all other slots are left alone. The \a method must be 0 if \a
- receiver is left out, so you cannot disconnect a
+ and all other slots are left alone. The \a method must be \nullptr
+ if \a receiver is left out, so you cannot disconnect a
specifically-named slot on all objects.
\sa connect()
@@ -3282,7 +3286,7 @@ QMetaObject::Connection QMetaObject::connect(const QObject *sender, int signal_i
\internal
Same as the QMetaObject::connect, but \a signal_index must be the result of QObjectPrivate::signalIndex
- method_index is relative to the rmeta metaobject, if rmeta is null, then it is absolute index
+ method_index is relative to the rmeta metaobject, if rmeta is \nullptr, then it is absolute index
the QObjectPrivate::Connection* has a refcount of 2, so it must be passed to a QMetaObject::Connection
*/
@@ -3675,10 +3679,12 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i
return;
}
- void *empty_argv[] = { 0 };
+ void *empty_argv[] = { nullptr };
+ if (!argv)
+ argv = empty_argv;
+
if (qt_signal_spy_callback_set.signal_begin_callback != 0) {
- qt_signal_spy_callback_set.signal_begin_callback(sender, signal_index,
- argv ? argv : empty_argv);
+ qt_signal_spy_callback_set.signal_begin_callback(sender, signal_index, argv);
}
Q_TRACE(QMetaObject_activate_begin_signal, sender, signal_index);
@@ -3741,7 +3747,7 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i
// put into the event queue
if ((c->connectionType == Qt::AutoConnection && !receiverInSameThread)
|| (c->connectionType == Qt::QueuedConnection)) {
- queued_activate(sender, signal_index, c, argv ? argv : empty_argv, locker);
+ queued_activate(sender, signal_index, c, argv, locker);
continue;
#if QT_CONFIG(thread)
} else if (c->connectionType == Qt::BlockingQueuedConnection) {
@@ -3753,8 +3759,8 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i
}
QSemaphore semaphore;
QMetaCallEvent *ev = c->isSlotObject ?
- new QMetaCallEvent(c->slotObj, sender, signal_index, 0, 0, argv ? argv : empty_argv, &semaphore) :
- new QMetaCallEvent(c->method_offset, c->method_relative, c->callFunction, sender, signal_index, 0, 0, argv ? argv : empty_argv, &semaphore);
+ new QMetaCallEvent(c->slotObj, sender, signal_index, 0, 0, argv, &semaphore) :
+ new QMetaCallEvent(c->method_offset, c->method_relative, c->callFunction, sender, signal_index, 0, 0, argv, &semaphore);
QCoreApplication::postEvent(receiver, ev);
locker.unlock();
semaphore.acquire();
@@ -3773,7 +3779,7 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i
QScopedPointer<QtPrivate::QSlotObjectBase, QSlotObjectBaseDeleter> obj(c->slotObj);
locker.unlock();
Q_TRACE(QMetaObject_activate_begin_slot_functor, obj.data());
- obj->call(receiver, argv ? argv : empty_argv);
+ obj->call(receiver, argv);
Q_TRACE(QMetaObject_activate_end_slot_functor, obj.data());
// Make sure the slot object gets destroyed before the mutex is locked again, as the
@@ -3789,10 +3795,10 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i
const auto callFunction = c->callFunction;
locker.unlock();
if (qt_signal_spy_callback_set.slot_begin_callback != 0)
- qt_signal_spy_callback_set.slot_begin_callback(receiver, methodIndex, argv ? argv : empty_argv);
+ qt_signal_spy_callback_set.slot_begin_callback(receiver, methodIndex, argv);
Q_TRACE(QMetaObject_activate_begin_slot, receiver, methodIndex);
- callFunction(receiver, QMetaObject::InvokeMetaMethod, method_relative, argv ? argv : empty_argv);
+ callFunction(receiver, QMetaObject::InvokeMetaMethod, method_relative, argv);
Q_TRACE(QMetaObject_activate_end_slot, receiver, methodIndex);
if (qt_signal_spy_callback_set.slot_end_callback != 0)
@@ -3803,13 +3809,11 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i
locker.unlock();
if (qt_signal_spy_callback_set.slot_begin_callback != 0) {
- qt_signal_spy_callback_set.slot_begin_callback(receiver,
- method,
- argv ? argv : empty_argv);
+ qt_signal_spy_callback_set.slot_begin_callback(receiver, method, argv);
}
Q_TRACE(QMetaObject_activate_begin_slot, receiver, method);
- metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv);
+ metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv);
Q_TRACE(QMetaObject_activate_end_slot, receiver, method);
if (qt_signal_spy_callback_set.slot_end_callback != 0)
@@ -3854,7 +3858,7 @@ void QMetaObject::activate(QObject *sender, int signal_index, void **argv)
It is different from QMetaObject::indexOfSignal(): indexOfSignal is the same as indexOfMethod
while QObjectPrivate::signalIndex is smaller because it doesn't give index to slots.
- If \a meta is not 0, it is set to the meta-object where the signal was found.
+ If \a meta is not \nullptr, it is set to the meta-object where the signal was found.
*/
int QObjectPrivate::signalIndex(const char *signalName,
const QMetaObject **meta) const
@@ -4987,8 +4991,8 @@ bool QObject::disconnect(const QMetaObject::Connection &connection)
0 may be used as a wildcard, meaning "any signal", "any receiving
object", or "any slot in the receiving object", respectively.
- The \a sender may never be 0. (You cannot disconnect signals from
- more than one object in a single call.)
+ The \a sender may never be \nullptr. (You cannot disconnect signals
+ from more than one object in a single call.)
If \a signal is 0, it disconnects \a receiver and \a method from
any signal. If not, only the specified signal is disconnected.
@@ -4999,8 +5003,8 @@ bool QObject::disconnect(const QMetaObject::Connection &connection)
If \a method is 0, it disconnects anything that is connected to \a
receiver. If not, only slots named \a method will be disconnected,
- and all other slots are left alone. The \a method must be 0 if \a
- receiver is left out, so you cannot disconnect a
+ and all other slots are left alone. The \a method must be \nullptr
+ if \a receiver is left out, so you cannot disconnect a
specifically-named slot on all objects.
\note It is not possible to use this overload to diconnect signals
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index aac9bcdee9..63c5a9ad73 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -176,7 +176,9 @@ public:
}
#ifndef QT_NO_REGEXP
+#if QT_DEPRECATED_SINCE(5, 13)
template<typename T>
+ QT_DEPRECATED_X("Use findChildren(const QRegularExpression &, ...) instead.")
inline QList<T> findChildren(const QRegExp &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
{
typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
@@ -186,6 +188,7 @@ public:
return list;
}
#endif
+#endif
#if QT_CONFIG(regularexpression)
template<typename T>
@@ -517,7 +520,10 @@ inline T qobject_cast(const QObject *object)
template <class T> inline const char * qobject_interface_iid()
{ return nullptr; }
-#if !defined(Q_MOC_RUN) && !defined(Q_CLANG_QDOC)
+
+#if defined(Q_CLANG_QDOC)
+# define Q_DECLARE_INTERFACE(IFace, IId)
+#elif !defined(Q_MOC_RUN)
# define Q_DECLARE_INTERFACE(IFace, IId) \
template <> inline const char *qobject_interface_iid<IFace *>() \
{ return IId; } \
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 5dfef786ec..a762e6f529 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -407,7 +407,7 @@ private:
class QBoolBlocker
{
- Q_DISABLE_COPY(QBoolBlocker)
+ Q_DISABLE_COPY_MOVE(QBoolBlocker)
public:
explicit inline QBoolBlocker(bool &b, bool value=true):block(b), reset(b){block = value;}
inline ~QBoolBlocker(){block = reset; }
@@ -432,9 +432,9 @@ struct Q_CORE_EXPORT QAbstractDynamicMetaObject : public QDynamicMetaObjectData,
{
~QAbstractDynamicMetaObject();
- virtual QAbstractDynamicMetaObject *toDynamicMetaObject(QObject *) override { return this; }
+ 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) override
+ 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_impl.h b/src/corelib/kernel/qobjectdefs_impl.h
index 8afff1fb98..aa6bd84e95 100644
--- a/src/corelib/kernel/qobjectdefs_impl.h
+++ b/src/corelib/kernel/qobjectdefs_impl.h
@@ -395,7 +395,7 @@ namespace QtPrivate {
protected:
~QSlotObjectBase() {}
private:
- Q_DISABLE_COPY(QSlotObjectBase)
+ Q_DISABLE_COPY_MOVE(QSlotObjectBase)
};
// implementation of QSlotObjectBase for which the slot is a pointer to member function of a QObject
diff --git a/src/corelib/kernel/qppsobject_p.h b/src/corelib/kernel/qppsobject_p.h
index abcf00fa05..a3bf3a5bc1 100644
--- a/src/corelib/kernel/qppsobject_p.h
+++ b/src/corelib/kernel/qppsobject_p.h
@@ -119,7 +119,7 @@ Q_SIGNALS:
private:
Q_DECLARE_PRIVATE(QPpsObject)
- Q_DISABLE_COPY(QPpsObject)
+ Q_DISABLE_COPY_MOVE(QPpsObject)
};
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
index 53c3136857..9d0394e4a5 100644
--- a/src/corelib/kernel/qsystemerror.cpp
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -152,10 +152,7 @@ QString QSystemError::string(ErrorScope errorScope, int errorCode)
case NativeError:
#if defined (Q_OS_WIN)
return windowsErrorString(errorCode);
-#else
- //unix: fall through as native and standard library are the same
- Q_FALLTHROUGH();
-#endif
+#endif // else unix: native and standard library are the same
case StandardLibraryError:
return standardLibraryErrorString(errorCode);
default:
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 929554f6bc..a2111a084f 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -61,14 +61,8 @@
#if defined(Q_OS_UNIX) && !defined(Q_OS_INTEGRITY)
#define QT_USE_MMAP
#include "private/qcore_unix_p.h"
-#endif
-
-// most of the headers below are already included in qplatformdefs.h
-// also this lacks Large File support but that's probably irrelevant
-#if defined(QT_USE_MMAP)
// for mmap
#include <sys/mman.h>
-#include <errno.h>
#endif
#include <stdlib.h>
@@ -303,7 +297,7 @@ public:
bool used_mmap : 1;
#endif
char *unmapPointer; // used memory (mmap, new or resource file)
- quint32 unmapLength;
+ qsizetype unmapLength;
// The resource object in case we loaded the translations from a resource
QResource *resource;
@@ -323,7 +317,7 @@ public:
uint numerusRulesLength;
bool do_load(const QString &filename, const QString &directory);
- bool do_load(const uchar *data, int len, const QString &directory);
+ bool do_load(const uchar *data, qsizetype len, const QString &directory);
QString do_translate(const char *context, const char *sourceText, const char *comment,
int n) const;
void clear();
@@ -554,7 +548,7 @@ bool QTranslatorPrivate::do_load(const QString &realname, const QString &directo
return false;
qint64 fileSize = file.size();
- if (fileSize < MagicLength || quint32(-1) <= fileSize)
+ if (fileSize < MagicLength || fileSize > std::numeric_limits<qsizetype>::max())
return false;
{
@@ -564,7 +558,7 @@ bool QTranslatorPrivate::do_load(const QString &realname, const QString &directo
return false;
}
- d->unmapLength = quint32(fileSize);
+ d->unmapLength = qsizetype(fileSize);
#ifdef QT_USE_MMAP
@@ -572,21 +566,20 @@ bool QTranslatorPrivate::do_load(const QString &realname, const QString &directo
#define MAP_FILE 0
#endif
#ifndef MAP_FAILED
-#define MAP_FAILED -1
+#define MAP_FAILED reinterpret_cast<void *>(-1)
#endif
int fd = file.handle();
if (fd >= 0) {
- char *ptr;
- ptr = reinterpret_cast<char *>(
- mmap(0, d->unmapLength, // any address, whole file
- PROT_READ, // read-only memory
- MAP_FILE | MAP_PRIVATE, // swap-backed map from file
- fd, 0)); // from offset 0 of fd
- if (ptr && ptr != reinterpret_cast<char *>(MAP_FAILED)) {
+ int protection = PROT_READ; // read-only memory
+ int flags = MAP_FILE | MAP_PRIVATE; // swap-backed map from file
+ void *ptr = QT_MMAP(nullptr, d->unmapLength,// any address, whole file
+ protection, flags,
+ fd, 0); // from offset 0 of fd
+ if (ptr != MAP_FAILED) {
file.close();
d->used_mmap = true;
- d->unmapPointer = ptr;
+ d->unmapPointer = static_cast<char *>(ptr);
ok = true;
}
}
@@ -816,7 +809,7 @@ static quint32 read32(const uchar *data)
return qFromBigEndian<quint32>(data);
}
-bool QTranslatorPrivate::do_load(const uchar *data, int len, const QString &directory)
+bool QTranslatorPrivate::do_load(const uchar *data, qsizetype len, const QString &directory)
{
bool ok = true;
const uchar *end = data + len;
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 090436a3c7..18c7f7648d 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1768,7 +1768,7 @@ Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names
\fn QVariant::QVariant(int typeId, const void *copy)
Constructs variant of type \a typeId, and initializes with
- \a copy if \a copy is not 0.
+ \a copy if \a copy is not \nullptr.
Note that you have to pass the address of the variable you want stored.
@@ -1797,7 +1797,7 @@ Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names
\internal
Constructs a variant private of type \a type, and initializes with \a copy if
- \a copy is not 0.
+ \a copy is not \nullptr.
*/
void QVariant::create(int type, const void *copy)
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index ff73c27b6e..f95502e75f 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -55,6 +55,8 @@
#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L
#include <variant>
+#elif defined(Q_CLANG_QDOC)
+namespace std { template<typename...> struct variant; }
#endif
QT_BEGIN_NAMESPACE
@@ -365,7 +367,7 @@ class Q_CORE_EXPORT QVariant
static inline QVariant fromValue(const T &value)
{ return qVariantFromValue(value); }
-#if defined(Q_CLANG_QDOC) || (QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L)
+#if QT_HAS_INCLUDE(<variant>) && __cplusplus >= 201703L
template<typename... Types>
static inline QVariant fromStdVariant(const std::variant<Types...> &value)
{