summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qvariant.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-07-19 12:58:36 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-07-20 14:57:32 -0700
commiteb9ace1cee4bb48005797b0b2d2d3d576a4cb4ce (patch)
tree5f3dcdfe77584e71360501c83232c6402fb6ada8 /src/corelib/kernel/qvariant.cpp
parent48675dfa33c4b99b41af487d75f057bb7399c709 (diff)
QVariant: add missing const to QMetaTypeInterface pointers
They're ALWAYS const objects, though they also chock full of relocations so they are never in read-only sections of memory (except maybe in final executables that are position-dependent). These are methods in a private sub-class of QVariant. No one outside of QtCore (at least qtbase) should be using them directly. QVariant doesn't have many friends (a bit anti-social); the one that matters is qvariant_cast and that one does access QVariant::Private. This is not a BC problem because QVariant::Private::type()'s signature is not changing. In any case, QVariant's Q_CORE_EXPORT does not apply to QVariant::Private anyway (see [1]). [1] https://msvc.godbolt.org/z/r9cer8eWh Pick-to: 6.3 6.4 Change-Id: I3859764fed084846bcb0fffd17035355f823dc8f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qvariant.cpp')
-rw-r--r--src/corelib/kernel/qvariant.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 55fe9d3c3f..472c510358 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -215,7 +215,7 @@ static qreal qConvertToRealNumber(const QVariant::Private *d, bool *ok)
// the type of d has already been set, but other field are not set
static void customConstruct(QVariant::Private *d, const void *copy)
{
- QtPrivate::QMetaTypeInterface *iface = d->typeInterface();
+ const QtPrivate::QMetaTypeInterface *iface = d->typeInterface();
if (!(iface && iface->size)) {
*d = QVariant::Private();
return;
@@ -494,11 +494,8 @@ QVariant::QVariant(const QVariant &p)
{
if (d.is_shared) {
d.data.shared->ref.ref();
- return;
- }
- QtPrivate::QMetaTypeInterface *iface = d.typeInterface();
- auto other = p.constData();
- if (iface) {
+ } else if (const QtPrivate::QMetaTypeInterface *iface = d.typeInterface()) {
+ auto other = p.constData();
if (other)
iface->copyCtr(iface, &d.data, other);
else
@@ -986,7 +983,7 @@ QVariant &QVariant::operator=(const QVariant &variant)
d = variant.d;
} else {
d = variant.d;
- QtPrivate::QMetaTypeInterface *iface = d.typeInterface();
+ const QtPrivate::QMetaTypeInterface *iface = d.typeInterface();
const void *other = variant.constData();
if (iface) {
if (other)