QMetaType: fix isRegistered()
It's not registered until an ID is assigned. Pick-to: 6.4 Change-Id: I3859764fed084846bcb0fffd17034f5b369c5b4d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
51905f8e76
commit
b1d9331c15
@ -468,6 +468,8 @@ const char *QtMetaTypePrivate::typedefNameForType(const QtPrivate::QMetaTypeInte
|
||||
|
||||
Returns \c true if this QMetaType object contains valid
|
||||
information about a type, false otherwise.
|
||||
|
||||
\sa isRegistered()
|
||||
*/
|
||||
bool QMetaType::isValid() const
|
||||
{
|
||||
@ -478,12 +480,15 @@ bool QMetaType::isValid() const
|
||||
\fn bool QMetaType::isRegistered() const
|
||||
\since 5.0
|
||||
|
||||
Returns \c true if this QMetaType object contains valid
|
||||
information about a type, false otherwise.
|
||||
Returns \c true if this QMetaType object has been registered with the Qt
|
||||
global metatype registry. Registration allows the type to be found by its
|
||||
name (using QMetaType::fromName()) or by its ID (using the constructor).
|
||||
|
||||
\sa qRegisterMetaType(), isValid()
|
||||
*/
|
||||
bool QMetaType::isRegistered() const
|
||||
{
|
||||
return d_ptr;
|
||||
return d_ptr && d_ptr->typeId.loadRelaxed();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -861,6 +861,7 @@ void tst_QMetaType::sizeOf()
|
||||
{
|
||||
QFETCH(int, type);
|
||||
QFETCH(size_t, size);
|
||||
ignoreInvalidMetaTypeWarning(type);
|
||||
QCOMPARE(size_t(QMetaType::sizeOf(type)), size);
|
||||
}
|
||||
|
||||
@ -873,6 +874,7 @@ void tst_QMetaType::sizeOfStaticLess()
|
||||
{
|
||||
QFETCH(int, type);
|
||||
QFETCH(size_t, size);
|
||||
ignoreInvalidMetaTypeWarning(type);
|
||||
QCOMPARE(size_t(QMetaType(type).sizeOf()), size);
|
||||
}
|
||||
|
||||
@ -909,6 +911,7 @@ void tst_QMetaType::alignOf()
|
||||
{
|
||||
QFETCH(int, type);
|
||||
QFETCH(size_t, size);
|
||||
ignoreInvalidMetaTypeWarning(type);
|
||||
QCOMPARE(size_t(QMetaType(type).alignOf()), size);
|
||||
}
|
||||
|
||||
@ -1534,6 +1537,12 @@ void tst_QMetaType::isRegisteredStaticLess()
|
||||
QCOMPARE(QMetaType(typeId).isRegistered(), registered);
|
||||
}
|
||||
|
||||
struct NotARegisteredType {};
|
||||
void tst_QMetaType::isNotRegistered()
|
||||
{
|
||||
QVERIFY(!QMetaType::fromType<NotARegisteredType>().isRegistered());
|
||||
}
|
||||
|
||||
typedef QHash<int, uint> IntUIntHash;
|
||||
Q_DECLARE_METATYPE(IntUIntHash)
|
||||
typedef QMap<int, uint> IntUIntMap;
|
||||
|
@ -84,6 +84,7 @@ private slots:
|
||||
void isRegistered();
|
||||
void isRegisteredStaticLess_data();
|
||||
void isRegisteredStaticLess();
|
||||
void isNotRegistered();
|
||||
void isEnum();
|
||||
void automaticTemplateRegistration_1();
|
||||
void automaticTemplateRegistration_2(); // defined in tst_qmetatype3.cpp
|
||||
|
Loading…
x
Reference in New Issue
Block a user