diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 4197fe9093..d0470ff796 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -787,7 +787,8 @@ const QVariant::Handler qt_dummy_variant_handler = { static void customConstruct(QVariant::Private *d, const void *copy) { - const uint size = QMetaType::sizeOf(d->type); + const QMetaType type(d->type); + const uint size = type.sizeOf(); if (!size) { d->type = QVariant::Invalid; return; @@ -795,11 +796,11 @@ static void customConstruct(QVariant::Private *d, const void *copy) // this logic should match with QVariantIntegrator::CanUseInternalSpace if (size <= sizeof(QVariant::Private::Data) - && (QMetaType::typeFlags(d->type) & QMetaType::MovableType)) { - QMetaType::construct(d->type, &d->data.ptr, copy); + && (type.flags() & QMetaType::MovableType)) { + type.construct(&d->data.ptr, copy); d->is_shared = false; } else { - void *ptr = QMetaType::create(d->type, copy); + void *ptr = type.create(copy); d->is_shared = true; d->data.shared = new QVariant::PrivateShared(ptr); } diff --git a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp index e842e18d52..f6b4d88311 100644 --- a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp @@ -90,6 +90,7 @@ struct BigClass double n,i,e,r,o,b; }; Q_STATIC_ASSERT(sizeof(BigClass) > sizeof(QVariant::Private::Data)); +Q_DECLARE_TYPEINFO(BigClass, Q_MOVABLE_TYPE); Q_DECLARE_METATYPE(BigClass); struct SmallClass @@ -97,6 +98,7 @@ struct SmallClass char s; }; Q_STATIC_ASSERT(sizeof(SmallClass) <= sizeof(QVariant::Private::Data)); +Q_DECLARE_TYPEINFO(SmallClass, Q_MOVABLE_TYPE); Q_DECLARE_METATYPE(SmallClass); void tst_qvariant::testBound()