diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-07-22 15:26:48 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-07-27 12:35:50 -0700 |
commit | 36b4aa111883fcd70c03f2bb8f61c9d22ab0b1aa (patch) | |
tree | 8cd31fdc94d3fbbea14e62e81b4a2ab77c4441a3 /src/corelib | |
parent | 3da89227feac3ba10275da762726e371617b611f (diff) |
QVariant::Private: replace QMetaType constructor with interface
And move it into the .cpp file, to hide the ugliness.
Change-Id: I3859764fed084846bcb0fffd17044729e361a42e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 10 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.h | 8 |
2 files changed, 9 insertions, 9 deletions
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 <typename T> inline QVariant::Private::Private(std::piecewise_construct_t, const T &t) : is_shared(!CanUseInternalSpace<T>), is_null(std::is_same_v<T, std::nullptr_t>) @@ -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 <typename T> 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; } |