diff options
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 6 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication_win.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 55 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobject.h | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobject_moc_p.h | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobjectbuilder.cpp | 22 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.cpp | 51 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 48 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype_p.h | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 68 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.h | 30 | ||||
-rw-r--r-- | src/corelib/kernel/qobject_p.h | 12 | ||||
-rw-r--r-- | src/corelib/kernel/qobjectdefs.h | 192 | ||||
-rw-r--r-- | src/corelib/kernel/qtmetamacros.h | 233 | ||||
-rw-r--r-- | src/corelib/kernel/qtranslator.cpp | 8 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 154 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.h | 16 |
17 files changed, 399 insertions, 507 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 34f54d8f94..dc46695f80 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -138,10 +138,10 @@ QT_BEGIN_NAMESPACE extern QString qAppFileName(); #endif -#if QT_VERSION >= 0x060000 -# error "Bump QCoreApplicatoinPrivate::app_compile_version to 0x060000" +#if QT_VERSION >= 0x070000 +# error "Bump QCoreApplicatoinPrivate::app_compile_version to 0x070000" #endif -int QCoreApplicationPrivate::app_compile_version = 0x050000; //we don't know exactly, but it's at least 5.0.0 +int QCoreApplicationPrivate::app_compile_version = 0x060000; //we don't know exactly, but it's at least 6.0.0 bool QCoreApplicationPrivate::setuidAllowed = false; diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index 765f129758..824c0535ed 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -772,7 +772,7 @@ QString decodeMSG(const MSG& msg) auto rect = reinterpret_cast<const RECT *>(lParam); QTextStream(¶meters) << "DPI: " << HIWORD(wParam) << ',' << LOWORD(wParam) << ' ' << (rect->right - rect->left) << 'x' - << (rect->bottom - rect->top) << forcesign << rect->left << rect->top; + << (rect->bottom - rect->top) << Qt::forcesign << rect->left << rect->top; } break; case WM_IME_NOTIFY: diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index fad47eee13..3883613d49 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -154,20 +154,29 @@ QT_BEGIN_NAMESPACE static inline const QMetaObjectPrivate *priv(const uint* data) { return reinterpret_cast<const QMetaObjectPrivate*>(data); } +static inline const char *rawStringData(const QMetaObject *mo, int index) +{ + Q_ASSERT(priv(mo->d.data)->revision >= 7); + uint offset = mo->d.stringdata[2*index]; + return reinterpret_cast<const char *>(mo->d.stringdata) + offset; +} + static inline const QByteArray stringData(const QMetaObject *mo, int index) { Q_ASSERT(priv(mo->d.data)->revision >= 7); - const QByteArrayDataPtr data = { const_cast<QByteArrayData*>(&mo->d.stringdata[index]) }; - Q_ASSERT(data.ptr->ref.isStatic()); - Q_ASSERT(data.ptr->alloc == 0); - Q_ASSERT(data.ptr->capacityReserved == 0); - Q_ASSERT(data.ptr->size >= 0); - return data; + uint offset = mo->d.stringdata[2*index]; + uint length = mo->d.stringdata[2*index + 1]; + const char *string = reinterpret_cast<const char *>(mo->d.stringdata) + offset; + return QByteArray::fromRawData(string, length); } -static inline const char *rawStringData(const QMetaObject *mo, int index) +static inline const char *rawTypeNameFromTypeInfo(const QMetaObject *mo, uint typeInfo) { - return stringData(mo, index).data(); + if (typeInfo & IsUnresolvedType) { + return rawStringData(mo, typeInfo & TypeNameIndexMask); + } else { + return QMetaType::typeName(typeInfo); + } } static inline QByteArray typeNameFromTypeInfo(const QMetaObject *mo, uint typeInfo) @@ -181,16 +190,11 @@ static inline QByteArray typeNameFromTypeInfo(const QMetaObject *mo, uint typeIn } } -static inline const char *rawTypeNameFromTypeInfo(const QMetaObject *mo, uint typeInfo) -{ - return typeNameFromTypeInfo(mo, typeInfo).constData(); -} - static inline int typeFromTypeInfo(const QMetaObject *mo, uint typeInfo) { if (!(typeInfo & IsUnresolvedType)) return typeInfo; - return QMetaType::type(stringData(mo, typeInfo & TypeNameIndexMask)); + return QMetaType::type(rawStringData(mo, typeInfo & TypeNameIndexMask)); } class QMetaMethodPrivate : public QMetaMethod @@ -577,7 +581,7 @@ static bool methodMatch(const QMetaObject *m, int handle, if (int(m->d.data[handle + 1]) != argc) return false; - if (stringData(m, m->d.data[handle]) != name) + if (rawStringData(m, m->d.data[handle]) != name) return false; int paramsIndex = m->d.data[handle + 2] + 1; @@ -682,7 +686,9 @@ static void argumentTypesFromString(const char *str, const char *end, --level; ++str; } - types += QArgumentType(QByteArray(begin, str - begin)); + QByteArray argType(begin, str - begin); + argType.replace("QList<", "QVector<"); + types += QArgumentType(std::move(argType)); } } @@ -1161,7 +1167,7 @@ QMetaProperty QMetaObject::property(int index) const const QMetaObject *scope = nullptr; if (qstrcmp(scope_name, "Qt") == 0) - scope = &QObject::staticQtMetaObject; + scope = &Qt::staticMetaObject; else scope = QMetaObject_findMetaObject(this, scope_name); if (scope) @@ -3655,6 +3661,21 @@ const char* QMetaClassInfo::value() const } /*! + \class QMethodRawArguments + \internal + + A wrapper class for the void ** arguments array used by the meta + object system. If a slot uses a single argument of this type, + the meta object system will pass the raw arguments array directly + to the slot and set the arguments count in the slot description to + zero, so that any signal can connect to it. + + This is used internally to implement signal relay functionality in + our state machine and dbus. +*/ + + +/*! \macro QGenericArgument Q_ARG(Type, const Type &value) \relates QMetaObject diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index fcd92afd89..31fecd0b07 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -46,9 +46,6 @@ QT_BEGIN_NAMESPACE - -template <typename T> class QList; - #define Q_METAMETHOD_INVOKE_MAX_ARGS 10 class Q_CORE_EXPORT QMetaMethod diff --git a/src/corelib/kernel/qmetaobject_moc_p.h b/src/corelib/kernel/qmetaobject_moc_p.h index 8c7900767b..471e43f85b 100644 --- a/src/corelib/kernel/qmetaobject_moc_p.h +++ b/src/corelib/kernel/qmetaobject_moc_p.h @@ -213,6 +213,9 @@ static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixSc } } + // Qt 5 compatibility, make sure we use the correct type name for QList + result.replace("QList<", "QVector<"); + return result; } diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index 4ecc340787..d02708540a 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -1103,13 +1103,13 @@ int QMetaStringTable::enter(const QByteArray &value) int QMetaStringTable::preferredAlignment() { - return Q_ALIGNOF(QByteArrayData); + return alignof(uint); } // Returns the size (in bytes) required for serializing this string table. int QMetaStringTable::blobSize() const { - int size = m_entries.size() * sizeof(QByteArrayData); + int size = m_entries.size() * 2*sizeof(uint); Entries::const_iterator it; for (it = m_entries.constBegin(); it != m_entries.constEnd(); ++it) size += it.key().size() + 1; @@ -1120,14 +1120,12 @@ static void writeString(char *out, int i, const QByteArray &str, const int offsetOfStringdataMember, int &stringdataOffset) { int size = str.size(); - qptrdiff offset = offsetOfStringdataMember + stringdataOffset - - i * sizeof(QByteArrayData); - const QByteArrayData data = - Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size, offset); + int offset = offsetOfStringdataMember + stringdataOffset; + uint offsetLen[2] = { uint(offset), uint(size) }; - memcpy(out + i * sizeof(QByteArrayData), &data, sizeof(QByteArrayData)); + memcpy(out + 2 * i * sizeof(uint), &offsetLen, 2*sizeof(uint)); - memcpy(out + offsetOfStringdataMember + stringdataOffset, str.constData(), size); + memcpy(out + offset, str.constData(), size); out[offsetOfStringdataMember + stringdataOffset + size] = '\0'; stringdataOffset += size + 1; @@ -1141,7 +1139,7 @@ void QMetaStringTable::writeBlob(char *out) const { Q_ASSERT(!(reinterpret_cast<quintptr>(out) & (preferredAlignment()-1))); - int offsetOfStringdataMember = m_entries.size() * sizeof(QByteArrayData); + int offsetOfStringdataMember = m_entries.size() * 2*sizeof(uint); int stringdataOffset = 0; // qt_metacast expects the first string in the string table to be the class name. @@ -1282,10 +1280,10 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, char *str = reinterpret_cast<char *>(buf + size); if (buf) { if (relocatable) { - meta->d.stringdata = reinterpret_cast<const QByteArrayData *>((quintptr)size); + meta->d.stringdata = reinterpret_cast<const uint *>((quintptr)size); meta->d.data = reinterpret_cast<uint *>((quintptr)pmetaSize); } else { - meta->d.stringdata = reinterpret_cast<const QByteArrayData *>(str); + meta->d.stringdata = reinterpret_cast<const uint *>(str); meta->d.data = reinterpret_cast<uint *>(data); } } @@ -1553,7 +1551,7 @@ void QMetaObjectBuilder::fromRelocatableData(QMetaObject *output, quintptr dataOffset = (quintptr)dataMo->d.data; output->d.superdata = superclass; - output->d.stringdata = reinterpret_cast<const QByteArrayData *>(buf + stringdataOffset); + output->d.stringdata = reinterpret_cast<const uint *>(buf + stringdataOffset); output->d.data = reinterpret_cast<const uint *>(buf + dataOffset); output->d.extradata = nullptr; output->d.relatedMetaObjects = nullptr; diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index af9a2e0dd2..79d6d0aa93 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -37,6 +37,8 @@ ** ****************************************************************************/ +#include <bitset> + #include "qmetatype.h" #include "qmetatype_p.h" #include "qobjectdefs.h" @@ -537,13 +539,12 @@ struct DefinedTypesFilter { #define QT_ADD_STATIC_METATYPE_ALIASES_ITER(MetaTypeName, MetaTypeId, AliasingName, RealNameStr) \ { RealNameStr, sizeof(RealNameStr) - 1, QMetaType::MetaTypeName }, -#define QT_ADD_STATIC_METATYPE_HACKS_ITER(MetaTypeName, TypeId, Name) \ - QT_ADD_STATIC_METATYPE(MetaTypeName, MetaTypeName, Name) + static const struct { const char * typeName; int typeNameLength; int type; } types[] = { QT_FOR_EACH_STATIC_TYPE(QT_ADD_STATIC_METATYPE) QT_FOR_EACH_STATIC_ALIAS_TYPE(QT_ADD_STATIC_METATYPE_ALIASES_ITER) - QT_FOR_EACH_STATIC_HACKS_TYPE(QT_ADD_STATIC_METATYPE_HACKS_ITER) + QT_ADD_STATIC_METATYPE(_, QMetaTypeId2<qreal>::MetaType, qreal) {nullptr, 0, QMetaType::UnknownType} }; @@ -2457,6 +2458,50 @@ const QMetaObject *metaObjectForQWidget() return nullptr; return qMetaObjectWidgetsHelper; } + +void qt5CompatibilityHookPostRegister(int id, const QByteArray &normalizedTypeName) +{ + // In Qt6 QList got typedef'ed to QVector. To keep runtime behavior compatibility + // with Qt5 we install corresponding aliases. For example if one register + // QVector<QVector<int>> + // we need to register the type plus all possible aliases: + // QVector<QList<int>> + // QList<QVector<int>> + // QList<QList<int>> + // ### Qt6 TODO This is slow, as it allocates couple of strings we would need to + // if def this call with something like QT_NO_QLIST + const char *vectorName = "QVector<"; + const char *listName = "QList<"; + + auto isSubstringOfAType = [](char c) { return c != ' ' && c != ',' && c != '<'; }; + QVarLengthArray<int> indexes; + + for (auto containerName: {vectorName, listName}) { + for (int i = normalizedTypeName.indexOf(containerName, 0); i != -1; i = normalizedTypeName.indexOf(containerName, i + 1)) { + if (!i || (i > 0 && !isSubstringOfAType(normalizedTypeName[i - 1]))) + indexes.append(i); + } + } + // To avoid problems with the constantly changing size we start replacements + // from the end of normalizedTypeName + std::sort(indexes.rbegin(), indexes.rend()); + + for (quint64 combination = 1; ; ++combination) { + std::bitset<64> bits(combination); + QByteArray name = normalizedTypeName; + for (auto j = 0; j < indexes.size(); ++j) { + if (bits.test(j)) { + auto i = indexes[j]; + auto replaceFrom = normalizedTypeName[i + 1] == 'V' ? vectorName : listName; + auto replaceTo = normalizedTypeName[i + 1] == 'V' ? listName : vectorName; + name.replace(i, sizeof(replaceFrom), replaceTo); + } + } + QMetaType::registerNormalizedTypedef(name, id); + if (bits.count() >= size_t(indexes.size())) + break; + } +} } namespace QtMetaTypePrivate { diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 825f767425..7628f5f6b3 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -151,6 +151,13 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId(); F(QVariantHash, 28, QVariantHash) \ F(QByteArrayList, 49, QByteArrayList) \ +#if QT_CONFIG(shortcut) +#define QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F)\ + F(QKeySequence, 75, QKeySequence) +#else +#define QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F) +#endif + #define QT_FOR_EACH_STATIC_GUI_CLASS(F)\ F(QFont, 64, QFont) \ F(QPixmap, 65, QPixmap) \ @@ -163,7 +170,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId(); F(QRegion, 72, QRegion) \ F(QBitmap, 73, QBitmap) \ F(QCursor, 74, QCursor) \ - F(QKeySequence, 75, QKeySequence) \ + QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F) \ F(QPen, 76, QPen) \ F(QTextLength, 77, QTextLength) \ F(QTextFormat, 78, QTextFormat) \ @@ -180,10 +187,6 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId(); #define QT_FOR_EACH_STATIC_WIDGETS_CLASS(F)\ F(QSizePolicy, 121, QSizePolicy) \ -// ### FIXME kill that set -#define QT_FOR_EACH_STATIC_HACKS_TYPE(F)\ - F(QMetaTypeId2<qreal>::MetaType, -1, qreal) - // F is a tuple: (QMetaType::TypeName, QMetaType::TypeNameID, AliasingType, "RealType") #define QT_FOR_EACH_STATIC_ALIAS_TYPE(F)\ F(ULong, -1, ulong, "unsigned long") \ @@ -200,10 +203,11 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId(); F(UInt, -1, uint, "quint32") \ F(LongLong, -1, qlonglong, "qint64") \ F(ULongLong, -1, qulonglong, "quint64") \ + F(QVariantList, -1, QVariantList, "QVector<QVariant>") \ F(QVariantList, -1, QVariantList, "QList<QVariant>") \ F(QVariantMap, -1, QVariantMap, "QMap<QString,QVariant>") \ F(QVariantHash, -1, QVariantHash, "QHash<QString,QVariant>") \ - F(QByteArrayList, -1, QByteArrayList, "QList<QByteArray>") \ + F(QByteArrayList, -1, QByteArrayList, "QVector<QByteArray>") \ #define QT_FOR_EACH_STATIC_TYPE(F)\ QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F)\ @@ -218,7 +222,6 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId(); TypeName = Id, #define QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(F) \ - F(QList) \ F(QVector) \ F(QQueue) \ F(QStack) \ @@ -500,7 +503,7 @@ public: typedef void (*Deleter)(void *); typedef void *(*Creator)(const void *); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if 1 || QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt6: fix this typedef void (*Destructor)(void *); typedef void *(*Constructor)(void *, const void *); // TODO Qt6: remove me #endif @@ -748,8 +751,6 @@ private: static bool registerDebugStreamOperatorFunction(const QtPrivate::AbstractDebugStreamFunction *f, int type); #endif -// ### 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_CLANG_QDOC template<typename, bool> friend struct QtPrivate::ValueTypeIsMetaType; template<typename, typename> friend struct QtPrivate::ConverterMemberFunction; @@ -759,9 +760,6 @@ private: template<typename, bool> friend struct QtPrivate::IsMetaTypePair; template<typename, typename> friend struct QtPrivate::MetaTypeSmartPointerHelper; #endif -#else -public: -#endif static bool registerConverterFunction(const QtPrivate::AbstractConverterFunction *f, int from, int to); static void unregisterConverterFunction(int from, int to); private: @@ -1009,10 +1007,6 @@ struct ContainerAPI : CapabilitiesImpl<T> }; template<typename T> -struct ContainerAPI<QList<T> > : CapabilitiesImpl<QList<T> > -{ static int size(const QList<T> *t) { return t->size(); } }; - -template<typename T> struct ContainerAPI<QVector<T> > : CapabilitiesImpl<QVector<T> > { static int size(const QVector<T> *t) { return t->size(); } }; @@ -1658,6 +1652,23 @@ namespace QtPrivate static bool registerConverter(int) { return false; } }; + template<class T> + struct Qt5CompatibilityHook + { + static inline void postRegister(int, const QByteArray &) {}; + }; + + Q_CORE_EXPORT void qt5CompatibilityHookPostRegister(int id, const QByteArray &normalizedTypeName); + + template<class T> + struct Qt5CompatibilityHook<QVector<T>> + { + static inline void postRegister(int id, const QByteArray &normalizedTypeName) + { + qt5CompatibilityHookPostRegister(id, normalizedTypeName); + } + }; + Q_CORE_EXPORT bool isBuiltinType(const QByteArray &type); } // namespace QtPrivate @@ -1784,6 +1795,7 @@ int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normaliz QtPrivate::AssociativeContainerConverterHelper<T>::registerConverter(id); QtPrivate::MetaTypePairHelper<T>::registerConverter(id); QtPrivate::MetaTypeSmartPointerHelper<T>::registerConverter(id); + QtPrivate::Qt5CompatibilityHook<T>::postRegister(id, normalizedTypeName); } return id; @@ -2007,7 +2019,7 @@ typedef QHash<QString, QVariant> QVariantHash; #ifdef Q_CLANG_QDOC class QByteArrayList; #else -typedef QList<QByteArray> QByteArrayList; +typedef QVector<QByteArray> QByteArrayList; #endif #define Q_DECLARE_METATYPE_TEMPLATE_1ARG(SINGLE_ARG_TEMPLATE) \ diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h index d743d5a5c7..f2057e25b4 100644 --- a/src/corelib/kernel/qmetatype_p.h +++ b/src/corelib/kernel/qmetatype_p.h @@ -232,9 +232,6 @@ template<> struct TypeDefinition<QRegExp> { static const bool IsAvailable = fals #if !QT_CONFIG(regularexpression) template<> struct TypeDefinition<QRegularExpression> { static const bool IsAvailable = false; }; #endif -#ifdef QT_NO_SHORTCUT -template<> struct TypeDefinition<QKeySequence> { static const bool IsAvailable = false; }; -#endif #ifdef QT_NO_CURSOR template<> struct TypeDefinition<QCursor> { static const bool IsAvailable = false; }; #endif diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index a51b794604..133ccc88d9 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -161,7 +161,6 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *) #endif void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject *) = nullptr; -void (*QAbstractDeclarativeData::destroyed_qml1)(QAbstractDeclarativeData *, QObject *) = nullptr; void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = nullptr; void (*QAbstractDeclarativeData::signalEmitted)(QAbstractDeclarativeData *, QObject *, int, void **) = nullptr; int (*QAbstractDeclarativeData::receivers)(QAbstractDeclarativeData *, const QObject *, int) = nullptr; @@ -234,10 +233,6 @@ QObjectPrivate::~QObjectPrivate() if (metaObject) metaObject->objectDestroyed(q_ptr); -#ifndef QT_NO_USERDATA - if (extraData) - qDeleteAll(extraData->userData); -#endif delete extraData; } @@ -997,15 +992,8 @@ QObject::~QObject() emit destroyed(this); } - if (d->declarativeData) { - if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) { - if (QAbstractDeclarativeData::destroyed_qml1) - QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this); - } else { - if (QAbstractDeclarativeData::destroyed) - QAbstractDeclarativeData::destroyed(d->declarativeData, this); - } - } + if (d->declarativeData && QAbstractDeclarativeData::destroyed) + QAbstractDeclarativeData::destroyed(d->declarativeData, this); QObjectPrivate::ConnectionData *cd = d->connections.loadRelaxed(); if (cd) { @@ -4249,58 +4237,6 @@ void QObject::dumpObjectInfo() const } } -#ifndef QT_NO_USERDATA -static QBasicAtomicInteger<uint> user_data_registration = Q_BASIC_ATOMIC_INITIALIZER(0); - -/*! - \internal - */ -uint QObject::registerUserData() -{ - return user_data_registration.fetchAndAddRelaxed(1); -} - -/*! - \fn QObjectUserData::QObjectUserData() - \internal - */ - -/*! - \internal - */ -QObjectUserData::~QObjectUserData() -{ -} - -/*! - \internal - */ -void QObject::setUserData(uint id, QObjectUserData* data) -{ - Q_D(QObject); - if (!d->extraData) - d->extraData = new QObjectPrivate::ExtraData; - - if (d->extraData->userData.size() <= (int) id) - d->extraData->userData.resize((int) id + 1); - d->extraData->userData[id] = data; -} - -/*! - \internal - */ -QObjectUserData* QObject::userData(uint id) const -{ - Q_D(const QObject); - if (!d->extraData) - return nullptr; - if ((int)id < d->extraData->userData.size()) - return d->extraData->userData.at(id); - return nullptr; -} - -#endif // QT_NO_USERDATA - #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QObject *o) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index f5d7c22e3a..8d9cc3ab83 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -78,12 +78,6 @@ class QRegExp; #if QT_CONFIG(regularexpression) class QRegularExpression; #endif -#if !QT_DEPRECATED_SINCE(5, 14) || QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -# define QT_NO_USERDATA -#endif -#ifndef QT_NO_USERDATA -class QObjectUserData; -#endif struct QDynamicMetaObjectData; typedef QList<QObject*> QObjectList; @@ -408,15 +402,6 @@ public: QList<QByteArray> dynamicPropertyNames() const; #endif // QT_NO_PROPERTIES -#ifndef QT_NO_USERDATA - QT_DEPRECATED_VERSION_5_14 - static uint registerUserData(); - QT_DEPRECATED_VERSION_X_5_14("Use setProperty()") - void setUserData(uint id, QObjectUserData* data); - QT_DEPRECATED_VERSION_X_5_14("Use property()") - QObjectUserData* userData(uint id) const; -#endif // QT_NO_USERDATA - Q_SIGNALS: void destroyed(QObject * = nullptr); void objectNameChanged(const QString &objectName, QPrivateSignal); @@ -449,9 +434,6 @@ protected: protected: QScopedPointer<QObjectData> d_ptr; - static const QMetaObject staticQtMetaObject; - friend inline const QMetaObject *qt_getQtMetaObject() noexcept; - friend struct QMetaObject; friend struct QMetaObjectPrivate; friend class QMetaCallEvent; @@ -482,18 +464,6 @@ inline QMetaObject::Connection QObject::connect(const QObject *asender, const ch const char *amember, Qt::ConnectionType atype) const { return connect(asender, asignal, this, amember, atype); } -inline const QMetaObject *qt_getQtMetaObject() noexcept -{ return &QObject::staticQtMetaObject; } - -#ifndef QT_NO_USERDATA -class Q_CORE_EXPORT QObjectUserData { - Q_DISABLE_COPY(QObjectUserData) -public: - QObjectUserData() = default; - virtual ~QObjectUserData(); -}; -#endif - #if QT_DEPRECATED_SINCE(5, 0) template<typename T> inline QT_DEPRECATED T qFindChild(const QObject *o, const QString &name = QString()) diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 838a9aa8c5..d6e73fbefc 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -89,7 +89,6 @@ class Q_CORE_EXPORT QAbstractDeclarativeData { public: static void (*destroyed)(QAbstractDeclarativeData *, QObject *); - static void (*destroyed_qml1)(QAbstractDeclarativeData *, QObject *); static void (*parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *); static void (*signalEmitted)(QAbstractDeclarativeData *, QObject *, int, void **); static int (*receivers)(QAbstractDeclarativeData *, const QObject *, int); @@ -97,14 +96,6 @@ public: static void (*setWidgetParent)(QObject *, QObject *); // Used by the QML engine to specify parents for widgets. Set by QtWidgets. }; -// This is an implementation of QAbstractDeclarativeData that is identical with -// the implementation in QtDeclarative and QtQml for the first bit -struct QAbstractDeclarativeDataImpl : public QAbstractDeclarativeData -{ - quint32 ownedByQml1:1; - quint32 unused: 31; -}; - class Q_CORE_EXPORT QObjectPrivate : public QObjectData { Q_DECLARE_PUBLIC(QObject) @@ -113,9 +104,6 @@ public: struct ExtraData { ExtraData() {} - #ifndef QT_NO_USERDATA - QVector<QObjectUserData *> userData; - #endif QList<QByteArray> propertyNames; QVector<QVariant> propertyValues; QVector<int> runningTimers; diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index dc2d832fe5..657cb9940b 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -46,199 +46,15 @@ #endif #include <QtCore/qnamespace.h> - #include <QtCore/qobjectdefs_impl.h> +#include <QtCore/qtmetamacros.h> QT_BEGIN_NAMESPACE - class QByteArray; struct QArrayData; -typedef QArrayData QByteArrayData; class QString; -#ifndef Q_MOC_OUTPUT_REVISION -#define Q_MOC_OUTPUT_REVISION 67 -#endif - -// The following macros can be defined by tools that understand Qt -// to have the information from the macro. -#ifndef QT_ANNOTATE_CLASS -# define QT_ANNOTATE_CLASS(type, ...) -#endif -#ifndef QT_ANNOTATE_CLASS2 -# define QT_ANNOTATE_CLASS2(type, a1, a2) -#endif -#ifndef QT_ANNOTATE_FUNCTION -# define QT_ANNOTATE_FUNCTION(x) -#endif -#ifndef QT_ANNOTATE_ACCESS_SPECIFIER -# define QT_ANNOTATE_ACCESS_SPECIFIER(x) -#endif - -// The following macros are our "extensions" to C++ -// They are used, strictly speaking, only by the moc. - -#ifndef Q_MOC_RUN -#ifndef QT_NO_META_MACROS -# if defined(QT_NO_KEYWORDS) -# define QT_NO_EMIT -# else -# ifndef QT_NO_SIGNALS_SLOTS_KEYWORDS -# define slots Q_SLOTS -# define signals Q_SIGNALS -# endif -# endif -# define Q_SLOTS QT_ANNOTATE_ACCESS_SPECIFIER(qt_slot) -# define Q_SIGNALS public QT_ANNOTATE_ACCESS_SPECIFIER(qt_signal) -# define Q_PRIVATE_SLOT(d, signature) QT_ANNOTATE_CLASS2(qt_private_slot, d, signature) -# define Q_EMIT -#ifndef QT_NO_EMIT -# define emit -#endif -#ifndef Q_CLASSINFO -# define Q_CLASSINFO(name, value) -#endif -#define Q_PLUGIN_METADATA(x) QT_ANNOTATE_CLASS(qt_plugin_metadata, x) -#define Q_INTERFACES(x) QT_ANNOTATE_CLASS(qt_interfaces, x) -#define Q_PROPERTY(...) QT_ANNOTATE_CLASS(qt_property, __VA_ARGS__) -#define Q_PRIVATE_PROPERTY(d, text) QT_ANNOTATE_CLASS2(qt_private_property, d, text) -#ifndef Q_REVISION -# define Q_REVISION(v) -#endif -#define Q_OVERRIDE(text) QT_ANNOTATE_CLASS(qt_override, text) -#define QDOC_PROPERTY(text) QT_ANNOTATE_CLASS(qt_qdoc_property, text) -#define Q_ENUMS(x) QT_ANNOTATE_CLASS(qt_enums, x) -#define Q_FLAGS(x) QT_ANNOTATE_CLASS(qt_enums, x) -#define Q_ENUM_IMPL(ENUM) \ - friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ - friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } -#define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x) -#define Q_FLAG(x) Q_FLAGS(x) Q_ENUM_IMPL(x) -#define Q_ENUM_NS_IMPL(ENUM) \ - inline Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ - inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } -#define Q_ENUM_NS(x) Q_ENUMS(x) Q_ENUM_NS_IMPL(x) -#define Q_FLAG_NS(x) Q_FLAGS(x) Q_ENUM_NS_IMPL(x) -#define Q_SCRIPTABLE QT_ANNOTATE_FUNCTION(qt_scriptable) -#define Q_INVOKABLE QT_ANNOTATE_FUNCTION(qt_invokable) -#define Q_SIGNAL QT_ANNOTATE_FUNCTION(qt_signal) -#define Q_SLOT QT_ANNOTATE_FUNCTION(qt_slot) -#endif // QT_NO_META_MACROS - -#ifndef QT_NO_TRANSLATION -// full set of tr functions -# define QT_TR_FUNCTIONS \ - 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 = nullptr, int n = -1) \ - { return staticMetaObject.tr(s, c, n); } -#else -// inherit the ones from QObject -# define QT_TR_FUNCTIONS -#endif - -#ifdef Q_CLANG_QDOC -#define QT_TR_FUNCTIONS -#endif - -// ### Qt6: remove -#define Q_OBJECT_CHECK /* empty, unused since Qt 5.2 */ - -#if defined(Q_CC_INTEL) -// Cannot redefine the visibility of a method in an exported class -# define Q_DECL_HIDDEN_STATIC_METACALL -#else -# define Q_DECL_HIDDEN_STATIC_METACALL Q_DECL_HIDDEN -#endif - -#if defined(Q_CC_CLANG) && Q_CC_CLANG >= 306 -# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_CLANG("-Winconsistent-missing-override") -#elif defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 501 -# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_GCC("-Wsuggest-override") -#else -# define Q_OBJECT_NO_OVERRIDE_WARNING -#endif - -#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 600 -# define Q_OBJECT_NO_ATTRIBUTES_WARNING QT_WARNING_DISABLE_GCC("-Wattributes") -#else -# define Q_OBJECT_NO_ATTRIBUTES_WARNING -#endif - -/* qmake ignore Q_OBJECT */ -#define Q_OBJECT \ -public: \ - QT_WARNING_PUSH \ - Q_OBJECT_NO_OVERRIDE_WARNING \ - static const QMetaObject staticMetaObject; \ - virtual const QMetaObject *metaObject() const; \ - virtual void *qt_metacast(const char *); \ - virtual int qt_metacall(QMetaObject::Call, int, void **); \ - QT_TR_FUNCTIONS \ -private: \ - Q_OBJECT_NO_ATTRIBUTES_WARNING \ - Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ - QT_WARNING_POP \ - struct QPrivateSignal {}; \ - QT_ANNOTATE_CLASS(qt_qobject, "") - -/* qmake ignore Q_OBJECT */ -#define Q_OBJECT_FAKE Q_OBJECT QT_ANNOTATE_CLASS(qt_fake, "") - -#ifndef QT_NO_META_MACROS -/* qmake ignore Q_GADGET */ -#define Q_GADGET \ -public: \ - static const QMetaObject staticMetaObject; \ - void qt_check_for_QGADGET_macro(); \ - typedef void QtGadgetHelper; \ -private: \ - QT_WARNING_PUSH \ - Q_OBJECT_NO_ATTRIBUTES_WARNING \ - Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ - QT_WARNING_POP \ - QT_ANNOTATE_CLASS(qt_qgadget, "") \ - /*end*/ - -/* qmake ignore Q_NAMESPACE_EXPORT */ -#define Q_NAMESPACE_EXPORT(...) \ - extern __VA_ARGS__ const QMetaObject staticMetaObject; \ - QT_ANNOTATE_CLASS(qt_qnamespace, "") \ - /*end*/ - -/* qmake ignore Q_NAMESPACE */ -#define Q_NAMESPACE Q_NAMESPACE_EXPORT() \ - /*end*/ - -#endif // QT_NO_META_MACROS - -#else // Q_MOC_RUN -#define slots slots -#define signals signals -#define Q_SLOTS Q_SLOTS -#define Q_SIGNALS Q_SIGNALS -#define Q_CLASSINFO(name, value) Q_CLASSINFO(name, value) -#define Q_INTERFACES(x) Q_INTERFACES(x) -#define Q_PROPERTY(text) Q_PROPERTY(text) -#define Q_PRIVATE_PROPERTY(d, text) Q_PRIVATE_PROPERTY(d, text) -#define Q_REVISION(v) Q_REVISION(v) -#define Q_OVERRIDE(text) Q_OVERRIDE(text) -#define Q_ENUMS(x) Q_ENUMS(x) -#define Q_FLAGS(x) Q_FLAGS(x) -#define Q_ENUM(x) Q_ENUM(x) -#define Q_FLAGS(x) Q_FLAGS(x) - /* qmake ignore Q_OBJECT */ -#define Q_OBJECT Q_OBJECT - /* qmake ignore Q_OBJECT */ -#define Q_OBJECT_FAKE Q_OBJECT_FAKE - /* qmake ignore Q_GADGET */ -#define Q_GADGET Q_GADGET -#define Q_SCRIPTABLE Q_SCRIPTABLE -#define Q_INVOKABLE Q_INVOKABLE -#define Q_SIGNAL Q_SIGNAL -#define Q_SLOT Q_SLOT -#endif //Q_MOC_RUN #ifndef QT_NO_META_MACROS // macro for onaming members @@ -285,6 +101,10 @@ class QMetaEnum; class QMetaProperty; class QMetaClassInfo; +struct QMethodRawArguments +{ + void **arguments; +}; class Q_CORE_EXPORT QGenericArgument { @@ -603,7 +423,7 @@ struct Q_CORE_EXPORT QMetaObject struct { // private data SuperData superdata; - const QByteArrayData *stringdata; + const uint *stringdata; const uint *data; typedef void (*StaticMetacallFunction)(QObject *, QMetaObject::Call, int, void **); StaticMetacallFunction static_metacall; diff --git a/src/corelib/kernel/qtmetamacros.h b/src/corelib/kernel/qtmetamacros.h new file mode 100644 index 0000000000..19b6bfa358 --- /dev/null +++ b/src/corelib/kernel/qtmetamacros.h @@ -0,0 +1,233 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2019 Olivier Goffart <ogoffart@woboq.com> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTMETAMACROS_H +#define QTMETAMACROS_H + +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE + +#ifndef Q_MOC_OUTPUT_REVISION +#define Q_MOC_OUTPUT_REVISION 67 +#endif + +// The following macros can be defined by tools that understand Qt +// to have the information from the macro. +#ifndef QT_ANNOTATE_CLASS +# define QT_ANNOTATE_CLASS(type, ...) +#endif +#ifndef QT_ANNOTATE_CLASS2 +# define QT_ANNOTATE_CLASS2(type, a1, a2) +#endif +#ifndef QT_ANNOTATE_FUNCTION +# define QT_ANNOTATE_FUNCTION(x) +#endif +#ifndef QT_ANNOTATE_ACCESS_SPECIFIER +# define QT_ANNOTATE_ACCESS_SPECIFIER(x) +#endif + +// The following macros are our "extensions" to C++ +// They are used, strictly speaking, only by the moc. + +#ifndef Q_MOC_RUN +#ifndef QT_NO_META_MACROS +# if defined(QT_NO_KEYWORDS) +# define QT_NO_EMIT +# else +# ifndef QT_NO_SIGNALS_SLOTS_KEYWORDS +# define slots Q_SLOTS +# define signals Q_SIGNALS +# endif +# endif +# define Q_SLOTS QT_ANNOTATE_ACCESS_SPECIFIER(qt_slot) +# define Q_SIGNALS public QT_ANNOTATE_ACCESS_SPECIFIER(qt_signal) +# define Q_PRIVATE_SLOT(d, signature) QT_ANNOTATE_CLASS2(qt_private_slot, d, signature) +# define Q_EMIT +#ifndef QT_NO_EMIT +# define emit +#endif +#ifndef Q_CLASSINFO +# define Q_CLASSINFO(name, value) +#endif +#define Q_PLUGIN_METADATA(x) QT_ANNOTATE_CLASS(qt_plugin_metadata, x) +#define Q_INTERFACES(x) QT_ANNOTATE_CLASS(qt_interfaces, x) +#define Q_PROPERTY(...) QT_ANNOTATE_CLASS(qt_property, __VA_ARGS__) +#define Q_PRIVATE_PROPERTY(d, text) QT_ANNOTATE_CLASS2(qt_private_property, d, text) +#ifndef Q_REVISION +# define Q_REVISION(v) +#endif +#define Q_OVERRIDE(text) QT_ANNOTATE_CLASS(qt_override, text) +#define QDOC_PROPERTY(text) QT_ANNOTATE_CLASS(qt_qdoc_property, text) +#define Q_ENUMS(x) QT_ANNOTATE_CLASS(qt_enums, x) +#define Q_FLAGS(x) QT_ANNOTATE_CLASS(qt_enums, x) +#define Q_ENUM_IMPL(ENUM) \ + friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ + friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } +#define Q_ENUM(x) Q_ENUMS(x) Q_ENUM_IMPL(x) +#define Q_FLAG(x) Q_FLAGS(x) Q_ENUM_IMPL(x) +#define Q_ENUM_NS_IMPL(ENUM) \ + inline Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) noexcept { return &staticMetaObject; } \ + inline Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) noexcept { return #ENUM; } +#define Q_ENUM_NS(x) Q_ENUMS(x) Q_ENUM_NS_IMPL(x) +#define Q_FLAG_NS(x) Q_FLAGS(x) Q_ENUM_NS_IMPL(x) +#define Q_SCRIPTABLE QT_ANNOTATE_FUNCTION(qt_scriptable) +#define Q_INVOKABLE QT_ANNOTATE_FUNCTION(qt_invokable) +#define Q_SIGNAL QT_ANNOTATE_FUNCTION(qt_signal) +#define Q_SLOT QT_ANNOTATE_FUNCTION(qt_slot) +#endif // QT_NO_META_MACROS + +#ifndef QT_NO_TRANSLATION +// full set of tr functions +# define QT_TR_FUNCTIONS \ + 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 = nullptr, int n = -1) \ + { return staticMetaObject.tr(s, c, n); } +#else +// inherit the ones from QObject +# define QT_TR_FUNCTIONS +#endif + +#ifdef Q_CLANG_QDOC +#define QT_TR_FUNCTIONS +#endif + +// ### Qt6: remove +#define Q_OBJECT_CHECK /* empty, unused since Qt 5.2 */ + +#if defined(Q_CC_INTEL) +// Cannot redefine the visibility of a method in an exported class +# define Q_DECL_HIDDEN_STATIC_METACALL +#else +# define Q_DECL_HIDDEN_STATIC_METACALL Q_DECL_HIDDEN +#endif + +#if defined(Q_CC_CLANG) && Q_CC_CLANG >= 306 +# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_CLANG("-Winconsistent-missing-override") +#elif defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 501 +# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_GCC("-Wsuggest-override") +#else +# define Q_OBJECT_NO_OVERRIDE_WARNING +#endif + +#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 600 +# define Q_OBJECT_NO_ATTRIBUTES_WARNING QT_WARNING_DISABLE_GCC("-Wattributes") +#else +# define Q_OBJECT_NO_ATTRIBUTES_WARNING +#endif + +/* qmake ignore Q_OBJECT */ +#define Q_OBJECT \ +public: \ + QT_WARNING_PUSH \ + Q_OBJECT_NO_OVERRIDE_WARNING \ + static const QMetaObject staticMetaObject; \ + virtual const QMetaObject *metaObject() const; \ + virtual void *qt_metacast(const char *); \ + virtual int qt_metacall(QMetaObject::Call, int, void **); \ + QT_TR_FUNCTIONS \ +private: \ + Q_OBJECT_NO_ATTRIBUTES_WARNING \ + Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ + QT_WARNING_POP \ + struct QPrivateSignal {}; \ + QT_ANNOTATE_CLASS(qt_qobject, "") + +/* qmake ignore Q_OBJECT */ +#define Q_OBJECT_FAKE Q_OBJECT QT_ANNOTATE_CLASS(qt_fake, "") + +#ifndef QT_NO_META_MACROS +/* qmake ignore Q_GADGET */ +#define Q_GADGET \ +public: \ + static const QMetaObject staticMetaObject; \ + void qt_check_for_QGADGET_macro(); \ + typedef void QtGadgetHelper; \ +private: \ + QT_WARNING_PUSH \ + Q_OBJECT_NO_ATTRIBUTES_WARNING \ + Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \ + QT_WARNING_POP \ + QT_ANNOTATE_CLASS(qt_qgadget, "") \ + /*end*/ + +/* qmake ignore Q_NAMESPACE_EXPORT */ +#define Q_NAMESPACE_EXPORT(...) \ + extern __VA_ARGS__ const QMetaObject staticMetaObject; \ + QT_ANNOTATE_CLASS(qt_qnamespace, "") \ + /*end*/ + +/* qmake ignore Q_NAMESPACE */ +#define Q_NAMESPACE Q_NAMESPACE_EXPORT() \ + /*end*/ + +#endif // QT_NO_META_MACROS + +#else // Q_MOC_RUN +#define slots slots +#define signals signals +#define Q_SLOTS Q_SLOTS +#define Q_SIGNALS Q_SIGNALS +#define Q_CLASSINFO(name, value) Q_CLASSINFO(name, value) +#define Q_INTERFACES(x) Q_INTERFACES(x) +#define Q_PROPERTY(text) Q_PROPERTY(text) +#define Q_PRIVATE_PROPERTY(d, text) Q_PRIVATE_PROPERTY(d, text) +#define Q_REVISION(v) Q_REVISION(v) +#define Q_OVERRIDE(text) Q_OVERRIDE(text) +#define Q_ENUMS(x) Q_ENUMS(x) +#define Q_FLAGS(x) Q_FLAGS(x) +#define Q_ENUM(x) Q_ENUM(x) +#define Q_FLAGS(x) Q_FLAGS(x) + /* qmake ignore Q_OBJECT */ +#define Q_OBJECT Q_OBJECT + /* qmake ignore Q_OBJECT */ +#define Q_OBJECT_FAKE Q_OBJECT_FAKE + /* qmake ignore Q_GADGET */ +#define Q_GADGET Q_GADGET +#define Q_SCRIPTABLE Q_SCRIPTABLE +#define Q_INVOKABLE Q_INVOKABLE +#define Q_SIGNAL Q_SIGNAL +#define Q_SLOT Q_SLOT +#endif //Q_MOC_RUN + +QT_END_NAMESPACE + +#endif // QTMETAMACROS_H diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index 93d75feafa..4bd8874630 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -58,11 +58,11 @@ #include "qendian.h" #include "qresource.h" -#if defined(Q_OS_UNIX) && !defined(Q_OS_INTEGRITY) -#define QT_USE_MMAP -#include "private/qcore_unix_p.h" +#if defined(Q_OS_UNIX) && !defined(Q_OS_NACL) && !defined(Q_OS_INTEGRITY) +# define QT_USE_MMAP +# include "private/qcore_unix_p.h" // for mmap -#include <sys/mman.h> +# include <sys/mman.h> #endif #include <stdlib.h> diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index f3ac3fcdba..888da17a98 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1470,7 +1470,7 @@ static void customConstruct(QVariant::Private *d, const void *copy) } else { // Private::Data contains long long, and long double is the biggest standard type. const size_t maxAlignment = - qMax(Q_ALIGNOF(QVariant::Private::Data), Q_ALIGNOF(long double)); + qMax(alignof(QVariant::Private::Data), alignof(long double)); const size_t s = sizeof(QVariant::PrivateShared); const size_t offset = s + ((s * maxAlignment - s) % maxAlignment); void *data = operator new(offset + size); @@ -2469,7 +2469,9 @@ static const ushort mapIdFromQt3ToCurrent[MapFromThreeCount] = QVariant::DateTime, QVariant::ByteArray, QVariant::BitArray, +#if QT_CONFIG(shortcut) QVariant::KeySequence, +#endif QVariant::Pen, QVariant::LongLong, QVariant::ULongLong, @@ -2574,7 +2576,11 @@ void QVariant::save(QDataStream &s) const typeId += 97; } else if (typeId == QMetaType::QSizePolicy) { typeId = 75; +#if QT_CONFIG(shortcut) } else if (typeId >= QMetaType::QKeySequence && typeId <= QMetaType::QQuaternion) { +#else + } else if (typeId >= QMetaType::QPen && typeId <= QMetaType::QQuaternion) { +#endif // and as a result these types received lower ids too typeId +=1; } else if (typeId == QMetaType::QPolygonF || typeId == QMetaType::QUuid) { @@ -3647,9 +3653,11 @@ bool QVariant::canConvert(int targetTypeId) const if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) { switch (uint(targetTypeId)) { case QVariant::Int: +#if QT_CONFIG(shortcut) if (currentType == QVariant::KeySequence) return true; Q_FALLTHROUGH(); +#endif case QVariant::UInt: case QVariant::LongLong: case QVariant::ULongLong: @@ -3672,11 +3680,16 @@ bool QVariant::canConvert(int targetTypeId) const return currentType == QVariant::Color || currentType == QMetaType::Nullptr || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); case QVariant::String: - return currentType == QVariant::KeySequence || currentType == QVariant::Font - || currentType == QVariant::Color || currentType == QMetaType::Nullptr - || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); + return currentType == QVariant::Font + || currentType == QVariant::Color || currentType == QMetaType::Nullptr +#if QT_CONFIG(shortcut) + || currentType == QVariant::KeySequence +#endif + || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); +#if QT_CONFIG(shortcut) case QVariant::KeySequence: return currentType == QVariant::String || currentType == QVariant::Int; +#endif case QVariant::Font: return currentType == QVariant::String; case QVariant::Color: @@ -3827,72 +3840,6 @@ bool QVariant::convert(const int type, void *ptr) const QMetaType::registerComparators(). */ -/*! - \fn bool QVariant::operator<(const QVariant &v) const - \obsolete - - Compares this QVariant with \a v and returns \c true if this is less than \a v. - - \note Comparability might not be availabe for the type stored in this QVariant - or in \a v. - - \warning To make this function work with a custom type registered with - qRegisterMetaType(), its comparison operator must be registered using - QMetaType::registerComparators(). - - This operator is deprecated as it cannot establish a total order required - for most use of this operator, which is the reason you cannot use QVariant - as the key of a QMap. -*/ - -/*! - \fn bool QVariant::operator<=(const QVariant &v) const - \obsolete - - Compares this QVariant with \a v and returns \c true if this is less or equal than \a v. - - \note Comparability might not be available for the type stored in this QVariant - or in \a v. - - \warning To make this function work with a custom type registered with - qRegisterMetaType(), its comparison operator must be registered using - QMetaType::registerComparators(). - - This operator is deprecated as it cannot establish a total order. -*/ - -/*! - \fn bool QVariant::operator>(const QVariant &v) const - \obsolete - - Compares this QVariant with \a v and returns \c true if this is larger than \a v. - - \note Comparability might not be available for the type stored in this QVariant - or in \a v. - - \warning To make this function work with a custom type registered with - qRegisterMetaType(), its comparison operator must be registered using - QMetaType::registerComparators(). - - This operator is deprecated as it cannot establish a total order. -*/ - -/*! - \fn bool QVariant::operator>=(const QVariant &v) const - \obsolete - - Compares this QVariant with \a v and returns \c true if this is larger or equal than \a v. - - \note Comparability might not be available for the type stored in this QVariant - or in \a v. - - \warning To make this function work with a custom type registered with - qRegisterMetaType(), its comparison operator must be registered using - QMetaType::registerComparators(). - - This operator is deprecated as it cannot establish a total order. -*/ - static bool qIsNumericType(uint tp) { static const qulonglong numericTypeBits = @@ -4073,73 +4020,6 @@ bool QVariant::cmp(const QVariant &v) const /*! \internal */ -int QVariant::compare(const QVariant &v) const -{ - // try numerics first, with C++ type promotion rules (no conversion) - if (qIsNumericType(d.type) && qIsNumericType(v.d.type)) - return numericCompare(&d, &v.d); - - // check for equality next, as more types implement operator== than operator< - if (cmp(v)) - return 0; - - const QVariant *v1 = this; - const QVariant *v2 = &v; - QVariant converted1; - QVariant converted2; - - if (d.type != v.d.type) { - // if both types differ, try to convert - if (v2->canConvert(v1->d.type)) { - converted2 = *v2; - if (converted2.convert(v1->d.type)) - v2 = &converted2; - } - if (v1->d.type != v2->d.type && v1->canConvert(v2->d.type)) { - converted1 = *v1; - if (converted1.convert(v2->d.type)) - v1 = &converted1; - } - if (v1->d.type != v2->d.type) { - // if conversion fails, default to toString - int r = v1->toString().compare(v2->toString(), Qt::CaseInsensitive); - if (r == 0) { - // cmp(v) returned false, so we should try to agree with it. - return (v1->d.type < v2->d.type) ? -1 : 1; - } - return r; - } - - // did we end up with two numerics? If so, restart - if (qIsNumericType(v1->d.type) && qIsNumericType(v2->d.type)) - return v1->compare(*v2); - } - if (v1->d.type >= QMetaType::User) { - int result; - if (QMetaType::compare(QT_PREPEND_NAMESPACE(constData(d)), QT_PREPEND_NAMESPACE(constData(v2->d)), d.type, &result)) - return result; - } - switch (v1->d.type) { - case QVariant::Date: - return v1->toDate() < v2->toDate() ? -1 : 1; - case QVariant::Time: - return v1->toTime() < v2->toTime() ? -1 : 1; - case QVariant::DateTime: - return v1->toDateTime() < v2->toDateTime() ? -1 : 1; - case QVariant::StringList: - return v1->toStringList() < v2->toStringList() ? -1 : 1; - } - int r = v1->toString().compare(v2->toString(), Qt::CaseInsensitive); - if (r == 0) { - // cmp(v) returned false, so we should try to agree with it. - return (d.type < v.d.type) ? -1 : 1; - } - return r; -} - -/*! - \internal - */ const void *QVariant::constData() const { diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 24657818c5..353bfa7ce7 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -184,7 +184,9 @@ class Q_CORE_EXPORT QVariant Region = QMetaType::QRegion, Bitmap = QMetaType::QBitmap, Cursor = QMetaType::QCursor, +#if QT_CONFIG(shortcut) KeySequence = QMetaType::QKeySequence, +#endif Pen = QMetaType::QPen, TextLength = QMetaType::QTextLength, TextFormat = QMetaType::QTextFormat, @@ -394,7 +396,7 @@ class Q_CORE_EXPORT QVariant struct Private { inline Private() noexcept : type(Invalid), is_shared(false), is_null(true) - { data.ptr = nullptr; } + {} // Internal constructor for initialized variants. explicit inline Private(uint variantType) noexcept @@ -410,6 +412,7 @@ class Q_CORE_EXPORT QVariant #endif union Data { + void *threeptr[3] = { nullptr, nullptr, nullptr }; char c; uchar uc; short s; @@ -463,16 +466,6 @@ class Q_CORE_EXPORT QVariant { return cmp(v); } inline bool operator!=(const QVariant &v) const { return !cmp(v); } -#if QT_DEPRECATED_SINCE(5, 15) - QT_DEPRECATED inline bool operator<(const QVariant &v) const - { return compare(v) < 0; } - QT_DEPRECATED inline bool operator<=(const QVariant &v) const - { return compare(v) <= 0; } - QT_DEPRECATED inline bool operator>(const QVariant &v) const - { return compare(v) > 0; } - QT_DEPRECATED inline bool operator>=(const QVariant &v) const - { return compare(v) >= 0; } -#endif protected: friend inline bool operator==(const QVariant &, const QVariantComparisonHelper &); @@ -491,7 +484,6 @@ public: Private d; void create(int type, const void *copy); bool cmp(const QVariant &other) const; - int compare(const QVariant &other) const; bool convert(const int t, void *ptr) const; // ### Qt6: drop const private: |