From 9c501b0670ec1b0a22255c6646c193c1b366c284 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 14 Jul 2020 22:35:47 +0200 Subject: [PATCH] Remove an unused enum value and document another one Change-Id: If9fed4f20242d789c1251b8798d7378d2d6911a6 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetatype.cpp | 2 +- src/corelib/kernel/qmetatype.h | 3 +- .../kernel/qmetatype/tst_qmetatype.cpp | 51 +++++++++--------- .../corelib/kernel/qmetatype/typeFlags.bin | Bin 106 -> 452 bytes 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index cf48e1fd78..76c9a2fa9c 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -408,10 +408,10 @@ Q_GLOBAL_STATIC(QMetaTypeCustomRegistry, customTypeRegistry) \value MovableType An instance of a type having this attribute can be safely moved by memcpy. \omitvalue SharedPointerToQObject \value IsEnumeration This type is an enumeration + \value If the type is an Enumeration, its underlying type is unsigned \value PointerToQObject This type is a pointer to a derived of QObject \omitvalue WeakPointerToQObject \omitvalue TrackingPointerToQObject - \omitvalue WasDeclaredAsMetaType \omitvalue IsGadget \omit This type is a Q_GADGET and it's corresponding QMetaObject can be accessed with QMetaType::metaObject Since 5.5. \endomit \omitvalue PointerToGadget */ diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 62d2fd82a1..1d3968abd0 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -354,11 +354,10 @@ public: SharedPointerToQObject = 0x20, WeakPointerToQObject = 0x40, TrackingPointerToQObject = 0x80, - WasDeclaredAsMetaType = 0x100, + IsUnsignedEnumeration = 0x100, IsGadget = 0x200, PointerToGadget = 0x400, IsPointer = 0x800, - IsUnsignedEnumeration = 0x1000 }; Q_DECLARE_FLAGS(TypeFlags, TypeFlag) diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 6f844e2fb4..9ecad3bdf6 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -203,8 +203,8 @@ private slots: void flags(); void flagsStaticLess_data(); void flagsStaticLess(); - void flagsBinaryCompatibility5_0_data(); - void flagsBinaryCompatibility5_0(); + void flagsBinaryCompatibility6_0_data(); + void flagsBinaryCompatibility6_0(); void construct_data(); void construct(); void typedConstruct(); @@ -411,7 +411,7 @@ void tst_QMetaType::registerGadget(const char *name, const QListd.static_metacall = &GadgetsStaticMetacallFunction; meta->d.superdata = nullptr; - const auto flags = QMetaType::WasDeclaredAsMetaType | QMetaType::IsGadget | QMetaType::NeedsConstruction | QMetaType::NeedsDestruction; + const auto flags = QMetaType::IsGadget | QMetaType::NeedsConstruction | QMetaType::NeedsDestruction; using TypeInfo = QtPrivate::QMetaTypeInterface; auto typeInfo = new TypeInfo { 0, sizeof(GenericGadgetType), alignof(GenericGadgetType), uint(flags), meta, name, 0, @@ -1133,46 +1133,47 @@ void tst_QMetaType::flagsStaticLess() QCOMPARE(bool(flags & QMetaType::MovableType), isMovable); } -void tst_QMetaType::flagsBinaryCompatibility5_0_data() +void tst_QMetaType::flagsBinaryCompatibility6_0_data() { - // Changing traits of a built-in type is illegal from BC point of view. - // Traits are saved in code of an application and in the Qt library which means - // that there may be a mismatch. - // The test is loading data generated by this code: - // - // QByteArray buffer; - // buffer.reserve(2 * QMetaType::User); - // for (quint32 i = 0; i < QMetaType::User; ++i) { - // if (QMetaType::isRegistered(i)) { - // buffer.append(i); - // buffer.append(quint32(QMetaType::typeFlags(i))); - // } - // } - // QFile file("/tmp/typeFlags.bin"); - // file.open(QIODevice::WriteOnly); - // file.write(buffer); - // file.close(); +// Changing traits of a built-in type is illegal from BC point of view. +// Traits are saved in code of an application and in the Qt library which means +// that there may be a mismatch. +// The test is loading data generated by this code: +// +// QList buffer; +// buffer.reserve(2 * QMetaType::User); +// for (quint32 i = 0; i < QMetaType::LastCoreType; ++i) { +// if (QMetaType::isRegistered(i)) { +// buffer.append(i); +// buffer.append(quint32(QMetaType::typeFlags(i))); +// } +// } +// QFile file("/tmp/typeFlags.bin"); +// file.open(QIODevice::WriteOnly); +// QDataStream ds(&file); +// ds << buffer; +// file.close(); QTest::addColumn("id"); QTest::addColumn("flags"); QFile file(QFINDTESTDATA("typeFlags.bin")); file.open(QIODevice::ReadOnly); - QByteArray buffer = file.readAll(); + QList buffer; + QDataStream ds(&file); + ds >> buffer; for (int i = 0; i < buffer.size(); i+=2) { const quint32 id = buffer.at(i); const quint32 flags = buffer.at(i + 1); if (id > QMetaType::LastCoreType) continue; // We do not link against QtGui, so we do longer consider such type as registered - if (id == QMetaType::Void) - continue; // The meaning of QMetaType::Void has changed in Qt6 QVERIFY2(QMetaType::isRegistered(id), "A type could not be removed in BC way"); QTest::newRow(QMetaType::typeName(id)) << id << flags; } } -void tst_QMetaType::flagsBinaryCompatibility5_0() +void tst_QMetaType::flagsBinaryCompatibility6_0() { QFETCH(quint32, id); QFETCH(quint32, flags); diff --git a/tests/auto/corelib/kernel/qmetatype/typeFlags.bin b/tests/auto/corelib/kernel/qmetatype/typeFlags.bin index 35d922a85c0e83f2831791b14b90e675fada5674..7d5d9c7a509e5b7162d50a77bc9a7c90d29fa14f 100644 GIT binary patch literal 452 zcmXZZRSE-95Jb@z_hjNieB$o1tL*R_{3`ifpI!Gn`|L3tZv~*ShbS qHuPKRygS@We+QM{MAq}8O3vJu6YtP8O17nAd96K>_>dd*R l3zufDT(eC3ktzRAzZzcmu~2N3`O