Add QMetaType::FirstCoreType enum value.

We should not assume that the first type id is 0.

Change-Id: I17ba6ba57e97ebd495904bfd11235fe458f214e5
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
This commit is contained in:
Jędrzej Nowacki 2012-02-13 13:01:59 +01:00 committed by Qt by Nokia
parent 1747f66457
commit 18965b1384
4 changed files with 5 additions and 3 deletions

View File

@ -184,6 +184,7 @@ public:
// these are merged with QVariant
QT_FOR_EACH_STATIC_TYPE(QT_DEFINE_METATYPE_ID)
FirstCoreType = Void,
LastCoreType = QModelIndex,
FirstGuiType = QFont,
LastGuiType = QPolygonF,

View File

@ -3542,6 +3542,7 @@ void tst_QVariant::loadQVariantFromDataStream(QDataStream::Version version)
stream >> typeName >> loadedVariant;
const int id = QMetaType::type(typeName.toLatin1());
QVariant constructedVariant(static_cast<QVariant::Type>(id));
QCOMPARE(constructedVariant.userType(), id);
QCOMPARE(QMetaType::typeName(loadedVariant.userType()), typeName.toLatin1().constData());
@ -3616,7 +3617,7 @@ void tst_QVariant::debugStream_data()
{
QTest::addColumn<QVariant>("variant");
QTest::addColumn<int>("typeId");
for (int id = QMetaType::Void; id < QMetaType::User; ++id) {
for (int id = 0; id < QMetaType::User; ++id) {
const char *tagName = QMetaType::typeName(id);
if (!tagName)
continue;

View File

@ -240,7 +240,7 @@ void tst_QMetaType::isRegisteredNotRegistered()
void tst_QMetaType::constructCoreType_data()
{
QTest::addColumn<int>("typeId");
for (int i = 0; i <= QMetaType::LastCoreType; ++i)
for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i)
QTest::newRow(QMetaType::typeName(i)) << i;
// GUI types are tested in tst_QGuiMetaType.
}

View File

@ -305,7 +305,7 @@ void tst_qvariant::stringVariantValue()
void tst_qvariant::createCoreType_data()
{
QTest::addColumn<int>("typeId");
for (int i = 0; i <= QMetaType::LastCoreType; ++i)
for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i)
QTest::newRow(QMetaType::typeName(i)) << i;
}