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>
This commit is contained in:
parent
d3735ff838
commit
6d3a886f09
@ -336,9 +336,11 @@ void tst_qvariant::stringVariantValue()
|
||||
void tst_qvariant::createCoreType_data()
|
||||
{
|
||||
QTest::addColumn<int>("typeId");
|
||||
for (int i = QMetaType::FirstCoreType; i <= QMetaType::LastCoreType; ++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
|
||||
// QVariant. The purpose of this benchmark is to measure the overhead
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user