summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-07-10 13:21:07 +0200
committerLars Knoll <lars.knoll@qt.io>2020-08-24 00:17:04 +0200
commitcb17157b2762ca5deebe16d4867346437acf3fe0 (patch)
tree375f628150b2925ef71af2da2e0c906047da2f70 /src/corelib/kernel
parent0daa9dbfc4c2d91dfa7110070834498693c6168a (diff)
Simplify the QVariant copy constructor and assignment operator
Change-Id: Id517dfc220adf06c5852745c92cfbe5e9c2e94a3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qvariant.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index c28476af17..104a7263b4 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1715,10 +1715,11 @@ QVariant::QVariant(const QVariant &p)
{
if (d.is_shared) {
d.data.shared->ref.ref();
- } else if (d.type().isValid()) {
- customConstruct(&d, p.constData());
- d.is_null = p.d.is_null;
+ return;
}
+ QMetaType t = d.type();
+ if (t.isValid())
+ t.construct(&d, p.constData());
}
#ifndef QT_NO_DATASTREAM
@@ -2200,8 +2201,9 @@ QVariant& QVariant::operator=(const QVariant &variant)
d = variant.d;
} else {
d = variant.d;
- customConstruct(&d, reinterpret_cast<const void *>(&variant.d.data));
- d.is_null = variant.d.is_null;
+ QMetaType t = d.type();
+ if (t.isValid())
+ t.construct(&d, variant.constData());
}
return *this;