From 6d3a886f09955fec29e541baa786633cce2b2b9e Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Tue, 26 Jan 2021 12:43:25 +0100 Subject: QVariant benchmark: fix crashes - Skip unused metatype id - Do not construct a QVariant from an int, when we instead want to construct a QVariant for a given metatype (was: metatype id in Qt 5) Pick-to: 6.0 Change-Id: I1ac19dec5549b424a9429f69999eaf8e96c022e2 Reviewed-by: Ulf Hermann --- tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tests/benchmarks/corelib/kernel/qvariant') diff --git a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp index d51b1e7a44..9664143608 100644 --- a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp @@ -336,8 +336,10 @@ void tst_qvariant::stringVariantValue() void tst_qvariant::createCoreType_data() { QTest::addColumn("typeId"); - for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i) - QTest::newRow(QMetaType::typeName(i)) << i; + for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++i) { + if (QMetaType::typeName(i)) // QMetaType(27) does not exist + QTest::newRow(QMetaType::typeName(i)) << i; + } } // Tests how fast a Qt core type can be default-constructed by a @@ -365,11 +367,12 @@ void tst_qvariant::createCoreTypeCopy_data() void tst_qvariant::createCoreTypeCopy() { QFETCH(int, typeId); - QVariant other(typeId); + QMetaType metaType(typeId); + QVariant other(metaType); const void *copy = other.constData(); QBENCHMARK { for (int i = 0; i < ITERATION_COUNT; ++i) - QVariant(QMetaType(typeId), copy); + QVariant(metaType, copy); } } -- cgit v1.2.3