diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-01-26 12:43:25 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-01-27 19:39:28 +0000 |
commit | 86af1842052bace1dcbbe79c621b210a5c0efc12 (patch) | |
tree | f462403a6c130211f3457aaa97ca734dc6fcdfeb | |
parent | f16f194a62a775641e28ef820ca1523d26625395 (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)
Change-Id: I1ac19dec5549b424a9429f69999eaf8e96c022e2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 6d3a886f09955fec29e541baa786633cce2b2b9e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp | 11 |
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); } } |