summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-01-26 12:43:25 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2021-01-27 15:00:56 +0100
commit6d3a886f09955fec29e541baa786633cce2b2b9e (patch)
tree0eb9db83ff0b276543395ad05e256fd1aeb017e4 /tests/benchmarks
parentd3735ff838767e53ead386dd3e5f099a15ca473c (diff)
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 <ulf.hermann@qt.io>
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp11
1 files changed, 7 insertions, 4 deletions
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<int>("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);
}
}