diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 7310fd9be2..3eba3685d0 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -298,6 +298,12 @@ static QVariant::Private clonePrivate(const QVariant::Private &other) } // anonymous used to hide QVariant handlers +inline QVariant::Private::Private(const QtPrivate::QMetaTypeInterface *iface) noexcept + : is_shared(false), is_null(false), packedType(quintptr(iface) >> 2) +{ + Q_ASSERT((quintptr(iface) & 0x3) == 0); +} + template inline QVariant::Private::Private(std::piecewise_construct_t, const T &t) : is_shared(!CanUseInternalSpace), is_null(std::is_same_v) @@ -826,7 +832,7 @@ QVariant::QVariant(const QVariant &p) \sa QVariant::fromValue(), QMetaType::Type */ -QVariant::QVariant(QMetaType type, const void *copy) : d(type) +QVariant::QVariant(QMetaType type, const void *copy) : d(type.iface()) { if (isValidMetaTypeForVariant(type.iface(), copy)) customConstruct(type.iface(), &d, copy); @@ -978,7 +984,7 @@ void QVariant::detach() return; Q_ASSERT(isValidMetaTypeForVariant(d.typeInterface(), constData())); - Private dd(d.type()); + Private dd(d.typeInterface()); customConstruct(d.typeInterface(), &dd, constData()); if (!d.data.shared->ref.deref()) customClear(&d); diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index aca2db2cbe..75da91b9e5 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -446,14 +446,8 @@ public: quintptr packedType : sizeof(QMetaType) * 8 - 2; constexpr Private() noexcept : is_shared(false), is_null(true), packedType(0) {} + explicit Private(const QtPrivate::QMetaTypeInterface *iface) noexcept; template explicit Private(std::piecewise_construct_t, const T &t); - explicit Private(QMetaType type) noexcept : is_shared(false), is_null(false) - { - quintptr mt = quintptr(type.d_ptr); - Q_ASSERT((mt & 0x3) == 0); - packedType = mt >> 2; - } - explicit Private(int type) noexcept : Private(QMetaType(type)) {} const void *storage() const { return is_shared ? data.shared->data() : &data.data; }