diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index cd9b6ad6c6..67bcacd751 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -2220,7 +2220,7 @@ public: static constexpr QMetaTypeInterface::DtorFn getDtor() { - if constexpr (std::is_destructible_v) + if constexpr (std::is_destructible_v && !std::is_trivially_destructible_v) return [](const QMetaTypeInterface *, void *addr) { reinterpret_cast(addr)->~S(); }; diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index c2ae5fb1dc..036ee42e05 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -270,10 +270,15 @@ static void customConstruct(QVariant::Private *d, const void *copy) static void customClear(QVariant::Private *d) { + auto iface = reinterpret_cast(d->packedType << 2); + if (!iface) + return; if (!d->is_shared) { - d->type().destruct(&d->data); + if (iface->dtor) + iface->dtor(iface, &d->data); } else { - d->type().destruct(d->data.shared->data()); + if (iface->dtor) + iface->dtor(iface, d->data.shared->data()); QVariant::PrivateShared::free(d->data.shared); } }