diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-10-20 10:22:07 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-10-23 09:50:16 +0200 |
commit | 1e0f2be5ac60884f0164f9b9dc2f8cffb21a969a (patch) | |
tree | 8eb2617a5acc84aa137ac86a697bb66db7f5f15e /src/corelib/kernel/qvariant.h | |
parent | 194f0ab50cef9be3cb40fc45861208493aca9d1d (diff) |
Do not store non relocatable types in QVariants internal storage
This mostly reverts change 76e8e8e9c8093f093cb9f37d61d273f43398fefb.
The reason is that storing non relocatable types inline in
QVariants storage would implicitly make QVariant non relocatable.
Fixes: QTBUG-87686
Change-Id: I2a09b1dcdd907d60085dccf17f987086dcba878c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qvariant.h')
-rw-r--r-- | src/corelib/kernel/qvariant.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index aa74aaa18f..012b5c52b6 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -442,9 +442,12 @@ class Q_CORE_EXPORT QVariant { static constexpr size_t MaxInternalSize = 3*sizeof(void *); template<typename T> - static constexpr bool CanUseInternalSpace = (sizeof(T) <= MaxInternalSize && alignof(T) <= alignof(double)); - static constexpr bool canUseInternalSpace(size_t s, size_t align) - { return s <= MaxInternalSize && align <= alignof(double); } + static constexpr bool CanUseInternalSpace = (QTypeInfo<T>::isRelocatable && sizeof(T) <= MaxInternalSize && alignof(T) <= alignof(double)); + static constexpr bool canUseInternalSpace(QMetaType type) + { + return type.flags() & QMetaType::RelocatableType && + size_t(type.sizeOf()) <= MaxInternalSize && size_t(type.alignOf()) <= alignof(double); + } union { |