summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/kernel/qmetatype.cpp5
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp12
2 files changed, 11 insertions, 6 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 410a5cc712..0be813f4f2 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -377,8 +377,9 @@ void QMetaType::registerStreamOperators(int idx, SaveOperator saveOp,
\sa type(), isRegistered(), Type
*/
-const char *QMetaType::typeName(int type)
+const char *QMetaType::typeName(int typeId)
{
+ const uint type = typeId;
// In theory it can be filled during compilation time, but for some reason template code
// that is able to do it causes GCC 4.6 to generate additional 3K of executable code. Probably
// it is not worth of it.
@@ -400,7 +401,7 @@ const char *QMetaType::typeName(int type)
} else {
const QVector<QCustomTypeInfo> * const ct = customTypes();
QReadLocker locker(customTypesLock());
- return ct && ct->count() > type - QMetaType::User && !ct->at(type - QMetaType::User).typeName.isEmpty()
+ return ct && uint(ct->count()) > type - QMetaType::User && !ct->at(type - QMetaType::User).typeName.isEmpty()
? ct->at(type - QMetaType::User).typeName.constData()
: 0;
}
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index f8403f11a1..35439885c9 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -305,16 +305,20 @@ void tst_QMetaType::normalizedTypes()
#define TYPENAME_DATA(MetaTypeName, MetaTypeId, RealType)\
QTest::newRow(#RealType) << QMetaType::MetaTypeName << #RealType;
-#define TYPENAME_DATA_ALIAS(MetaTypeName, MetaTypeId, AliasType, RealTypeString)\
- QTest::newRow(RealTypeString) << QMetaType::MetaTypeName << #AliasType;
-
void tst_QMetaType::typeName_data()
{
QTest::addColumn<QMetaType::Type>("aType");
QTest::addColumn<QString>("aTypeName");
QT_FOR_EACH_STATIC_TYPE(TYPENAME_DATA)
- QT_FOR_EACH_STATIC_ALIAS_TYPE(TYPENAME_DATA_ALIAS)
+
+ QTest::newRow("Whity<double>") << static_cast<QMetaType::Type>(::qMetaTypeId<Whity<double> >()) << QString::fromLatin1("Whity<double>");
+ QTest::newRow("Whity<int>") << static_cast<QMetaType::Type>(::qMetaTypeId<Whity<int> >()) << QString::fromLatin1("Whity<int>");
+ QTest::newRow("Testspace::Foo") << static_cast<QMetaType::Type>(::qMetaTypeId<TestSpace::Foo>()) << QString::fromLatin1("TestSpace::Foo");
+
+ QTest::newRow("-1") << QMetaType::Type(-1) << QString();
+ QTest::newRow("-124125534") << QMetaType::Type(-124125534) << QString();
+ QTest::newRow("124125534") << QMetaType::Type(124125534) << QString();
}
void tst_QMetaType::typeName()