summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qvariant.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-07-27 17:31:27 +0200
committerLars Knoll <lars.knoll@qt.io>2020-08-24 00:19:24 +0200
commit369cb1470d06b01934e616757ad98db2bb9ebb20 (patch)
tree80b16534be01cc1c8ab4e3e4c16bc96668a6587a /src/corelib/kernel/qvariant.cpp
parente7e7540aecc5a4a44f1d1a25e58ccbcf662cbe24 (diff)
Clean up int based convert() API
Pass QMetaType instances instead. Change-Id: I07366cea566fdebf5bb793aa8087f8109216ec0c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qvariant.cpp')
-rw-r--r--src/corelib/kernel/qvariant.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 7f75e1884f..b21ded3186 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1765,15 +1765,15 @@ QBitArray QVariant::toBitArray() const
template <typename T>
inline T qNumVariantToHelper(const QVariant::Private &d, bool *ok, const T& val)
{
- const uint t = qMetaTypeId<T>();
+ QMetaType t = QMetaType::fromType<T>();
if (ok)
*ok = true;
- if (d.typeId() == t)
+ if (d.type() == t)
return val;
T ret = 0;
- bool success = QMetaType::convert(d.storage(), d.typeId(), &ret, t);
+ bool success = QMetaType::convert(d.type(), d.storage(), t, &ret);
if (ok)
*ok = success;
return ret;
@@ -1871,11 +1871,12 @@ qulonglong QVariant::toULongLong(bool *ok) const
*/
bool QVariant::toBool() const
{
- if (d.type() == QMetaType::fromType<bool>())
+ auto boolType = QMetaType::fromType<bool>();
+ if (d.type() == boolType)
return d.get<bool>();
bool res = false;
- QMetaType::convert(constData(), d.typeId(), &res, QMetaType::Bool);
+ QMetaType::convert(d.type(), constData(), boolType, &res);
return res;
}
@@ -2027,7 +2028,7 @@ bool QVariant::convert(QMetaType targetType)
if (oldValue.d.is_null && oldValue.d.typeId() != QMetaType::Nullptr)
return false;
- bool ok = QMetaType::convert(oldValue.constData(), oldValue.d.typeId(), data(), targetType.id());
+ bool ok = QMetaType::convert(oldValue.d.type(), oldValue.constData(), targetType, data());
d.is_null = !ok;
return ok;
}
@@ -2039,7 +2040,7 @@ bool QVariant::convert(QMetaType targetType)
*/
bool QVariant::convert(const int type, void *ptr) const
{
- return QMetaType::convert(constData(), d.typeId(), ptr, type);
+ return QMetaType::convert(d.type(), constData(), QMetaType(type), ptr);
}