QMetaType: fix isRegistered()
It's not registered until an ID is assigned. Change-Id: I3859764fed084846bcb0fffd17034f5b369c5b4d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit b1d9331c156b7ff5c724600eee21ac50f4565868) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
fbdd3396c3
commit
c4cea61cea
@ -465,6 +465,8 @@ const char *QtMetaTypePrivate::typedefNameForType(const QtPrivate::QMetaTypeInte
|
|||||||
|
|
||||||
Returns \c true if this QMetaType object contains valid
|
Returns \c true if this QMetaType object contains valid
|
||||||
information about a type, false otherwise.
|
information about a type, false otherwise.
|
||||||
|
|
||||||
|
\sa isRegistered()
|
||||||
*/
|
*/
|
||||||
bool QMetaType::isValid() const
|
bool QMetaType::isValid() const
|
||||||
{
|
{
|
||||||
@ -475,12 +477,15 @@ bool QMetaType::isValid() const
|
|||||||
\fn bool QMetaType::isRegistered() const
|
\fn bool QMetaType::isRegistered() const
|
||||||
\since 5.0
|
\since 5.0
|
||||||
|
|
||||||
Returns \c true if this QMetaType object contains valid
|
Returns \c true if this QMetaType object has been registered with the Qt
|
||||||
information about a type, false otherwise.
|
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
|
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(int, type);
|
||||||
QFETCH(size_t, size);
|
QFETCH(size_t, size);
|
||||||
|
ignoreInvalidMetaTypeWarning(type);
|
||||||
QCOMPARE(size_t(QMetaType::sizeOf(type)), size);
|
QCOMPARE(size_t(QMetaType::sizeOf(type)), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -873,6 +874,7 @@ void tst_QMetaType::sizeOfStaticLess()
|
|||||||
{
|
{
|
||||||
QFETCH(int, type);
|
QFETCH(int, type);
|
||||||
QFETCH(size_t, size);
|
QFETCH(size_t, size);
|
||||||
|
ignoreInvalidMetaTypeWarning(type);
|
||||||
QCOMPARE(size_t(QMetaType(type).sizeOf()), size);
|
QCOMPARE(size_t(QMetaType(type).sizeOf()), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -909,6 +911,7 @@ void tst_QMetaType::alignOf()
|
|||||||
{
|
{
|
||||||
QFETCH(int, type);
|
QFETCH(int, type);
|
||||||
QFETCH(size_t, size);
|
QFETCH(size_t, size);
|
||||||
|
ignoreInvalidMetaTypeWarning(type);
|
||||||
QCOMPARE(size_t(QMetaType(type).alignOf()), size);
|
QCOMPARE(size_t(QMetaType(type).alignOf()), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1534,6 +1537,12 @@ void tst_QMetaType::isRegisteredStaticLess()
|
|||||||
QCOMPARE(QMetaType(typeId).isRegistered(), registered);
|
QCOMPARE(QMetaType(typeId).isRegistered(), registered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct NotARegisteredType {};
|
||||||
|
void tst_QMetaType::isNotRegistered()
|
||||||
|
{
|
||||||
|
QVERIFY(!QMetaType::fromType<NotARegisteredType>().isRegistered());
|
||||||
|
}
|
||||||
|
|
||||||
typedef QHash<int, uint> IntUIntHash;
|
typedef QHash<int, uint> IntUIntHash;
|
||||||
Q_DECLARE_METATYPE(IntUIntHash)
|
Q_DECLARE_METATYPE(IntUIntHash)
|
||||||
typedef QMap<int, uint> IntUIntMap;
|
typedef QMap<int, uint> IntUIntMap;
|
||||||
|
@ -84,6 +84,7 @@ private slots:
|
|||||||
void isRegistered();
|
void isRegistered();
|
||||||
void isRegisteredStaticLess_data();
|
void isRegisteredStaticLess_data();
|
||||||
void isRegisteredStaticLess();
|
void isRegisteredStaticLess();
|
||||||
|
void isNotRegistered();
|
||||||
void isEnum();
|
void isEnum();
|
||||||
void automaticTemplateRegistration_1();
|
void automaticTemplateRegistration_1();
|
||||||
void automaticTemplateRegistration_2(); // defined in tst_qmetatype3.cpp
|
void automaticTemplateRegistration_2(); // defined in tst_qmetatype3.cpp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user