From 0b92a93e8e165520b12cb8ca1d0a8812ed6e046b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 8 Sep 2020 12:33:23 +0200 Subject: Avoid various warnings about deprected QMetaType methods Change-Id: I8f4b2703fdd08ff341904219cec33c321e0511c7 Reviewed-by: Volker Hilsheimer --- src/imports/labsmodels/qqmldelegatecomponent.cpp | 4 ++-- src/imports/labsmodels/qqmltablemodel.cpp | 8 ++++---- src/imports/settings/qqmlsettings.cpp | 3 ++- .../qmldbg_debugger/qqmlenginedebugservice.cpp | 2 +- src/qml/jsruntime/qv4engine.cpp | 8 ++++---- src/qml/jsruntime/qv4qobjectwrapper.cpp | 16 ++++++++-------- src/qml/jsruntime/qv4variantobject.cpp | 4 ++-- src/qml/qml/qqmlbinding.cpp | 9 ++++----- src/qml/qml/qqmlmetaobject.cpp | 12 ++++++------ src/qml/qml/qqmlmetatype.cpp | 2 +- src/qml/qml/qqmlopenmetaobject.cpp | 4 ++-- src/qml/qml/qqmlproperty.cpp | 15 +++++++++------ src/qml/qml/qqmlpropertybinding.cpp | 13 ++++++------- src/qml/qml/qqmlpropertycache.cpp | 8 ++++---- src/qml/qml/qqmlpropertyvalidator.cpp | 12 ++++++------ src/qml/qml/qqmlvaluetypewrapper.cpp | 10 +++++----- src/qml/qml/qqmlvmemetaobject.cpp | 4 ++-- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 2 +- src/qmlmodels/qqmllistaccessor.cpp | 2 +- src/qmltest/quicktestresult.cpp | 4 +++- src/quick/util/qquickanimation.cpp | 4 ++-- 21 files changed, 75 insertions(+), 71 deletions(-) diff --git a/src/imports/labsmodels/qqmldelegatecomponent.cpp b/src/imports/labsmodels/qqmldelegatecomponent.cpp index b8eb8049b3..68c1d3d741 100644 --- a/src/imports/labsmodels/qqmldelegatecomponent.cpp +++ b/src/imports/labsmodels/qqmldelegatecomponent.cpp @@ -313,9 +313,9 @@ QQmlComponent *QQmlDelegateChooser::delegate(QQmlAdaptorModel *adaptorModel, int v = value(adaptorModel, row, column, QStringLiteral("modelData")); if (v.isValid()) { - if (v.canConvert(QMetaType::QVariantMap)) + if (v.canConvert(QMetaType(QMetaType::QVariantMap))) v = v.toMap().value(m_role); - else if (v.canConvert(QMetaType::QObjectStar)) + else if (v.canConvert(QMetaType(QMetaType::QObjectStar))) v = v.value()->property(m_role.toUtf8()); } } diff --git a/src/imports/labsmodels/qqmltablemodel.cpp b/src/imports/labsmodels/qqmltablemodel.cpp index 5a2d68780c..2a39184980 100644 --- a/src/imports/labsmodels/qqmltablemodel.cpp +++ b/src/imports/labsmodels/qqmltablemodel.cpp @@ -863,14 +863,14 @@ bool QQmlTableModel::setData(const QModelIndex &index, const QVariant &value, in const ColumnRoleMetadata roleData = columnMetadata.roles.value(roleName); QVariant effectiveValue = value; if (value.userType() != roleData.type) { - if (!value.canConvert(int(roleData.type))) { + if (!value.canConvert(QMetaType(roleData.type))) { qmlWarning(this).nospace() << "setData(): the value " << value << " set at row " << row << " column " << column << " with role " << roleName << " cannot be converted to " << roleData.typeName; return false; } - if (!effectiveValue.convert(int(roleData.type))) { + if (!effectiveValue.convert(QMetaType(roleData.type))) { qmlWarning(this).nospace() << "setData(): failed converting value " << value << " set at row " << row << " column " << column << " with role " << roleName << " to " << roleData.typeName; @@ -1045,7 +1045,7 @@ bool QQmlTableModel::validateNewRow(const char *functionName, const QVariant &ro const QVariant rolePropertyValue = rowAsMap.value(roleData.name); if (rolePropertyValue.userType() != roleData.type) { - if (!rolePropertyValue.canConvert(int(roleData.type))) { + if (!rolePropertyValue.canConvert(QMetaType(roleData.type))) { qmlWarning(this).quote() << functionName << ": expected the property named " << roleData.name << " to be of type " << roleData.typeName << ", but got " << QString::fromLatin1(rolePropertyValue.typeName()) @@ -1054,7 +1054,7 @@ bool QQmlTableModel::validateNewRow(const char *functionName, const QVariant &ro } QVariant effectiveValue = rolePropertyValue; - if (!effectiveValue.convert(int(roleData.type))) { + if (!effectiveValue.convert(QMetaType(roleData.type))) { qmlWarning(this).nospace() << functionName << ": failed converting value " << rolePropertyValue << " set at column " << columnIndex << " with role " << QString::fromLatin1(rolePropertyValue.typeName()) << " to " diff --git a/src/imports/settings/qqmlsettings.cpp b/src/imports/settings/qqmlsettings.cpp index de45f87638..50308b30a9 100644 --- a/src/imports/settings/qqmlsettings.cpp +++ b/src/imports/settings/qqmlsettings.cpp @@ -335,7 +335,8 @@ void QQmlSettingsPrivate::load() const QVariant currentValue = instance()->value(property.name(), previousValue); if (!currentValue.isNull() && (!previousValue.isValid() - || (currentValue.canConvert(previousValue.userType()) && previousValue != currentValue))) { + || (currentValue.canConvert(previousValue.metaType()) + && previousValue != currentValue))) { property.write(q, currentValue); qCDebug(lcSettings) << "QQmlSettings: load" << property.name() << "setting:" << currentValue << "default:" << previousValue; } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp index 1a92bfc79a..5dcfbf2e0f 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp @@ -99,7 +99,7 @@ static bool isSaveable(const QVariant &value) return false; NullDevice nullDevice; QDataStream fakeStream(&nullDevice); - return QMetaType::save(fakeStream, valType, value.constData()); + return QMetaType(valType).save(fakeStream, value.constData()); } QQmlEngineDebugServiceImpl::QQmlEngineDebugServiceImpl(QObject *parent) : diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index d1d8e47722..5d1fa758cd 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1830,7 +1830,7 @@ QV4::ReturnedValue QV4::ExecutionEngine::fromVariant(const QVariant &variant) a->arrayPut(ii, (v = QV4::QObjectWrapper::wrap(this, list.at(ii)))); a->setArrayLengthUnchecked(list.count()); return a.asReturnedValue(); - } else if (QMetaType::typeFlags(type) & QMetaType::PointerToQObject) { + } else if (QMetaType(type).flags() & QMetaType::PointerToQObject) { return QV4::QObjectWrapper::wrap(this, *reinterpret_cast(ptr)); } @@ -2338,11 +2338,11 @@ bool ExecutionEngine::metaTypeFromJS(const Value &value, int type, void *data) // Try to use magic; for compatibility with qjsvalue_cast. - QByteArray name = QMetaType::typeName(type); + QByteArray name = QMetaType(type).name(); if (convertToNativeQObject(value, name, reinterpret_cast(data))) return true; if (value.as() && name.endsWith('*')) { - int valueType = QMetaType::type(name.left(name.size()-1)); + int valueType = QMetaType::fromName(name.left(name.size()-1)).id(); QVariant &var = value.as()->d()->data(); if (valueType == var.userType()) { // We have T t, T* is requested, so return &t. @@ -2365,7 +2365,7 @@ bool ExecutionEngine::metaTypeFromJS(const Value &value, int type, void *data) canCast = qobject->qt_metacast(className) != nullptr; } if (canCast) { - QByteArray varTypeName = QMetaType::typeName(var.userType()); + QByteArray varTypeName = QMetaType(var.userType()).name(); if (varTypeName.endsWith('*')) *reinterpret_cast(data) = *reinterpret_cast(var.data()); else diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 95672a8635..ee3be6fcdc 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -464,10 +464,10 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP if (!property->isVarProperty() && property->propType() != qMetaTypeId()) { // assigning a JS function to a non var or QJSValue property or is not allowed. QString error = QLatin1String("Cannot assign JavaScript function to "); - if (!QMetaType::typeName(property->propType())) + if (!QMetaType(property->propType()).name()) error += QLatin1String("[unknown property type]"); else - error += QLatin1String(QMetaType::typeName(property->propType())); + error += QLatin1String(QMetaType(property->propType()).name()); scope.engine->throwError(error); return; } @@ -533,10 +533,10 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP PROPERTY_STORE(QJSValue, QJSValuePrivate::fromReturnedValue(value.asReturnedValue())); } else if (value.isUndefined() && property->propType() != qMetaTypeId()) { QString error = QLatin1String("Cannot assign [undefined] to "); - if (!QMetaType::typeName(property->propType())) + if (!QMetaType(property->propType()).name()) error += QLatin1String("[unknown property type]"); else - error += QLatin1String(QMetaType::typeName(property->propType())); + error += QLatin1String(QMetaType(property->propType()).name()); scope.engine->throwError(error); return; } else if (value.as()) { @@ -576,9 +576,9 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP if (!QQmlPropertyPrivate::write(object, *property, v, callingQmlContext)) { const char *valueType = (v.userType() == QMetaType::UnknownType) ? "an unknown type" - : QMetaType::typeName(v.userType()); + : QMetaType(v.userType()).name(); - const char *targetTypeName = QMetaType::typeName(property->propType()); + const char *targetTypeName = QMetaType(property->propType()).name(); if (!targetTypeName) targetTypeName = "an unregistered type"; @@ -1441,7 +1441,7 @@ static int MatchScore(const QV4::Value &actual, int conversionType) case QMetaType::QJsonValue: return 0; default: { - const char *typeName = QMetaType::typeName(conversionType); + const char *typeName = QMetaType(conversionType).name(); if (typeName && typeName[strlen(typeName) - 1] == '*') return 0; else @@ -1471,7 +1471,7 @@ static int MatchScore(const QV4::Value &actual, int conversionType) const QVariant v = obj->engine()->toVariant(actual, -1); if (v.userType() == conversionType) return 0; - else if (v.canConvert(conversionType)) + else if (v.canConvert(QMetaType(conversionType))) return 5; return 10; } else if (conversionType == QMetaType::QJsonObject) { diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp index 9d7b3c6e9a..ee813b68de 100644 --- a/src/qml/jsruntime/qv4variantobject.cpp +++ b/src/qml/jsruntime/qv4variantobject.cpp @@ -139,7 +139,7 @@ ReturnedValue VariantPrototype::method_toString(const FunctionObject *b, const V RETURN_UNDEFINED(); const QVariant variant = o->d()->data(); QString result = variant.toString(); - if (result.isEmpty() && !variant.canConvert(QMetaType::QString)) { + if (result.isEmpty() && !variant.canConvert(QMetaType(QMetaType::QString))) { QDebug dbg(&result); dbg << variant; // QDebug appends a space, we're not interested in continuing the stream so we chop it off. @@ -167,7 +167,7 @@ ReturnedValue VariantPrototype::method_valueOf(const FunctionObject *b, const Va case QMetaType::Bool: return Encode(v.toBool()); default: - if (QMetaType::typeFlags(v.userType()) & QMetaType::IsEnumeration) + if (QMetaType(v.metaType()).flags() & QMetaType::IsEnumeration) RETURN_RESULT(Encode(v.toInt())); break; } diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index cdfbad2a35..3253c547ab 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -461,9 +461,8 @@ Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core, QVariant::fromValue(QJSValuePrivate::fromReturnedValue(result.asReturnedValue())), context(), flags); } else if (isUndefined) { - const QLatin1String typeName(QMetaType::typeName(type) - ? QMetaType::typeName(type) - : "[unknown property type]"); + const char *name = QMetaType(type).name(); + const QLatin1String typeName(name ? name : "[unknown property type]"); delayedError()->setErrorDescription(QLatin1String("Unable to assign [undefined] to ") + typeName); return false; @@ -494,13 +493,13 @@ Q_NEVER_INLINE bool QQmlBinding::slowWrite(const QQmlPropertyData &core, if (userType == QMetaType::Nullptr || userType == QMetaType::VoidStar) valueType = "null"; else - valueType = QMetaType::typeName(userType); + valueType = QMetaType(userType).name(); } if (!valueType) valueType = "undefined"; if (!propertyType) - propertyType = QMetaType::typeName(type); + propertyType = QMetaType(type).name(); if (!propertyType) propertyType = "[unknown property type]"; diff --git a/src/qml/qml/qqmlmetaobject.cpp b/src/qml/qml/qqmlmetaobject.cpp index 98fe9dccc6..057eb94f54 100644 --- a/src/qml/qml/qqmlmetaobject.cpp +++ b/src/qml/qml/qqmlmetaobject.cpp @@ -199,8 +199,8 @@ int QQmlMetaObject::methodReturnType(const QQmlPropertyData &data, QByteArray *u propTypeName = m.typeName(); } - if (QMetaType::sizeOf(type) <= int(sizeof(int))) { - if (QMetaType::typeFlags(type) & QMetaType::IsEnumeration) + if (QMetaType(type).sizeOf() <= qsizetype(sizeof(int))) { + if (QMetaType(type).flags() & QMetaType::IsEnumeration) return QMetaType::Int; if (isNamedEnumerator(metaObject(), propTypeName)) @@ -250,10 +250,10 @@ int *QQmlMetaObject::methodParameterTypes(int index, ArgTypeStorage *argStorage, for (int ii = 0; ii < argc; ++ii) { int type = m.parameterType(ii); - if (QMetaType::sizeOf(type) > int(sizeof(int))) { + if (QMetaType(type).sizeOf() > qsizetype(sizeof(int))) { // Cannot be passed as int // We know that it's a known type, as sizeOf(UnknownType) == 0 - } else if (QMetaType::typeFlags(type) & QMetaType::IsEnumeration) { + } else if (QMetaType(type).flags() & QMetaType::IsEnumeration) { type = QMetaType::Int; } else { if (argTypeNames.isEmpty()) @@ -291,10 +291,10 @@ int *QQmlMetaObject::methodParameterTypes(const QMetaMethod &m, ArgTypeStorage * for (int ii = 0; ii < argc; ++ii) { int type = m.parameterType(ii); - if (QMetaType::sizeOf(type) > int(sizeof(int))) { + if (QMetaType(type).sizeOf() > qsizetype(sizeof(int))) { // Cannot be passed as int // We know that it's a known type, as sizeOf(UnknownType) == 0 - } else if (QMetaType::typeFlags(type) & QMetaType::IsEnumeration) { + } else if (QMetaType(type).flags() & QMetaType::IsEnumeration) { type = QMetaType::Int; } else { if (argTypeNames.isEmpty()) diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 79ea83b6df..dea976c4ee 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -1529,7 +1529,7 @@ QString QQmlMetaType::prettyTypeName(const QObject *object) marker = typeName.indexOf(QLatin1String("_QML_")); if (marker != -1) { typeName = QStringView{typeName}.left(marker) + QLatin1Char('*'); - type = QQmlMetaType::qmlType(QMetaType::type(typeName.toLatin1())); + type = QQmlMetaType::qmlType(QMetaType::fromName(typeName.toLatin1()).id()); if (type.isValid()) { QString qmlTypeName = type.qmlTypeName(); const int lastSlash = qmlTypeName.lastIndexOf(QLatin1Char('/')); diff --git a/src/qml/qml/qqmlopenmetaobject.cpp b/src/qml/qml/qqmlopenmetaobject.cpp index fe0946c6de..e96e763d89 100644 --- a/src/qml/qml/qqmlopenmetaobject.cpp +++ b/src/qml/qml/qqmlopenmetaobject.cpp @@ -191,7 +191,7 @@ public: bool valueSet = false; QVariant value() const { - if (QMetaType::typeFlags(m_value.userType()) & QMetaType::PointerToQObject + if (m_value.metaType().flags() & QMetaType::PointerToQObject && qobjectTracker.isNull()) return QVariant::fromValue(nullptr); return m_value; @@ -200,7 +200,7 @@ public: void setValue(const QVariant &v) { m_value = v; valueSet = true; - if (QMetaType::typeFlags(v.userType()) & QMetaType::PointerToQObject) + if (v.metaType().flags() & QMetaType::PointerToQObject) qobjectTracker = m_value.value(); } }; diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 0de097e81e..afdec1d450 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -1150,12 +1150,13 @@ bool QQmlPropertyPrivate::writeEnumProperty(const QMetaProperty &prop, int idx, if (!ok) return false; } else if (v.userType() != QMetaType::Int && v.userType() != QMetaType::UInt) { - int enumMetaTypeId = QMetaType::type(QByteArray(menum.scope() + QByteArray("::") + menum.name())); + int enumMetaTypeId = QMetaType::fromName( + QByteArray(menum.scope() + QByteArray("::") + menum.name())).id(); if ((enumMetaTypeId == QMetaType::UnknownType) || (v.userType() != enumMetaTypeId) || !v.constData()) return false; v = QVariant(*reinterpret_cast(v.constData())); } - v.convert(QMetaType::Int); + v.convert(QMetaType(QMetaType::Int)); } // the status variable is changed by qt_metacall to indicate what it did @@ -1226,7 +1227,7 @@ bool QQmlPropertyPrivate::write( double integral; double fractional = std::modf(value.toDouble(), &integral); if (qFuzzyIsNull(fractional)) - v.convert(QMetaType::Int); + v.convert(QMetaType(QMetaType::Int)); } return writeEnumProperty(prop, property.coreIndex(), object, v, flags); } @@ -1265,7 +1266,9 @@ bool QQmlPropertyPrivate::write( } else { return false; } - } else if (value.canConvert(propertyType) && !isUrl && variantType != QMetaType::QString && propertyType != qMetaTypeId>() && !property.isQList()) { + } else if (value.canConvert(QMetaType(propertyType)) + && !isUrl && variantType != QMetaType::QString + && propertyType != qMetaTypeId>() && !property.isQList()) { // common cases: switch (propertyType) { case QMetaType::Bool: { @@ -1290,7 +1293,7 @@ bool QQmlPropertyPrivate::write( } default: { // "fallback": QVariant v = value; - v.convert(propertyType); + v.convert(QMetaType(propertyType)); return property.writeProperty(object, const_cast(v.constData()), flags); } } @@ -1367,7 +1370,7 @@ bool QQmlPropertyPrivate::write( if (!ok) { v = value; - if (v.convert(propertyType)) { + if (v.convert(QMetaType(propertyType))) { ok = true; } else if (v.isValid() && value.isNull()) { // For historical reasons converting a null QVariant to another type will do the trick diff --git a/src/qml/qml/qqmlpropertybinding.cpp b/src/qml/qml/qqmlpropertybinding.cpp index a528cf2754..b691bf39a9 100644 --- a/src/qml/qml/qqmlpropertybinding.cpp +++ b/src/qml/qml/qqmlpropertybinding.cpp @@ -123,11 +123,10 @@ bool QQmlPropertyBinding::evaluate(const QMetaType &metaType, void *dataPtr) } QVariant resultVariant(scope.engine->toVariant(result, metaType.id())); - auto metaTypeId = metaType.id(); - resultVariant.convert(metaTypeId); + resultVariant.convert(metaType); const bool hasChanged = !metaType.equals(resultVariant.constData(), dataPtr); - QMetaType::destruct(metaTypeId, dataPtr); - QMetaType::construct(metaTypeId, dataPtr, resultVariant.constData()); + metaType.destruct(dataPtr); + metaType.construct(dataPtr, resultVariant.constData()); return hasChanged; } @@ -139,11 +138,11 @@ QUntypedPropertyBinding QQmlTranslationPropertyBinding::create(const QQmlPropert QVariant resultVariant(compilationUnit->bindingValueAsString(binding)); if (metaType.id() != QMetaType::QString) - resultVariant.convert(metaType.id()); + resultVariant.convert(metaType); const bool hasChanged = !metaType.equals(resultVariant.constData(), dataPtr); - QMetaType::destruct(metaType.id(), dataPtr); - QMetaType::construct(metaType.id(), dataPtr, resultVariant.constData()); + metaType.destruct(dataPtr); + metaType.construct(dataPtr, resultVariant.constData()); return hasChanged; }; diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index 0e853f4e28..3c6c0c82de 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -657,7 +657,7 @@ void QQmlPropertyCache::resolve(QQmlPropertyData *data) const const char *retTy = metaMethod.typeName(); if (!retTy) retTy = "\0"; - data->setPropType(QMetaType::type(retTy)); + data->setPropType(QMetaType::fromName(retTy).id()); } else { auto metaProperty = mo->property(data->coreIndex()); data->setPropType(metaProperty.metaType().id()); @@ -1141,7 +1141,7 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) notifierId = data->notifyIndex() - signalHandlerIndexCacheStart; QMetaPropertyBuilder property = builder.addProperty(properties.at(ii).first.toUtf8(), - QMetaType::typeName(data->propType()), + QMetaType(data->propType()).name(), notifierId); property.setReadable(true); @@ -1154,7 +1154,7 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) QByteArray returnType; if (data->propType() != 0) - returnType = QMetaType::typeName(data->propType()); + returnType = QMetaType(data->propType()).name(); QByteArray signature; // '+=' reserves extra capacity. Follow-up appending will be probably free. @@ -1166,7 +1166,7 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) Q_ASSERT(arguments->argumentsValid); for (int ii = 0; ii < arguments->arguments[0]; ++ii) { if (ii != 0) signature.append(','); - signature.append(QMetaType::typeName(arguments->arguments[1 + ii])); + signature.append(QMetaType(arguments->arguments[1 + ii]).name()); } } diff --git a/src/qml/qml/qqmlpropertyvalidator.cpp b/src/qml/qml/qqmlpropertyvalidator.cpp index 7f7b2038a4..453ffc3542 100644 --- a/src/qml/qml/qqmlpropertyvalidator.cpp +++ b/src/qml/qml/qqmlpropertyvalidator.cpp @@ -311,7 +311,7 @@ QVector QQmlPropertyValidator::validateObject( binding->location, tr("Invalid grouped property access: Property \"%1\" with primitive type \"%2\".") .arg(name) - .arg(QString::fromLatin1(QMetaType::typeName(typeId))) + .arg(QString::fromLatin1(QMetaType(typeId).name())) ); } @@ -319,7 +319,7 @@ QVector QQmlPropertyValidator::validateObject( return recordError(binding->location, tr("Invalid grouped property access: Property \"%1\" with type \"%2\", which is not a value type") .arg(name) - .arg(QString::fromLatin1(QMetaType::typeName(typeId))) + .arg(QString::fromLatin1(QMetaType(typeId).name())) ); } } @@ -642,7 +642,7 @@ QQmlError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache *prope // otherwise, try a custom type assignment QQmlMetaType::StringConverter converter = QQmlMetaType::customStringConverter(property->propType()); if (!converter) { - return warnOrError(tr("Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QMetaType::typeName(property->propType())))); + return warnOrError(tr("Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QMetaType(property->propType()).name()))); } } break; @@ -737,7 +737,7 @@ QQmlError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *propert } else if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerObject && property->isFunction()) { return noError; } else if (isPrimitiveType(propType)) { - auto typeName = QString::fromUtf8(QMetaType::typeName(propType)); + auto typeName = QString::fromUtf8(QMetaType(propType).name()); return qQmlCompileError(binding->location, tr("Cannot assign value of type \"%1\" to property \"%2\", expecting \"%3\"") .arg(rhsType()) .arg(propertyName) @@ -766,11 +766,11 @@ QQmlError QQmlPropertyValidator::validateObjectBinding(QQmlPropertyData *propert if (!isAssignable) { return qQmlCompileError(binding->valueLocation, tr("Cannot assign object of type \"%1\" to property of type \"%2\" as the former is neither the same as the latter nor a sub-class of it.") - .arg(rhsType()).arg(QLatin1String(QMetaType::typeName(propType)))); + .arg(rhsType()).arg(QLatin1String(QMetaType(propType).name()))); } } else { return qQmlCompileError(binding->valueLocation, tr("Cannot assign to property of unknown type \"%1\".") - .arg(QLatin1String(QMetaType::typeName(propType)))); + .arg(QLatin1String(QMetaType(propType).name()))); } } diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 272b8ebfc7..1bc1674fae 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -238,8 +238,8 @@ bool QQmlValueTypeWrapper::toGadget(void *data) const if (!ref->readReferenceValue()) return false; const int typeId = d()->valueType()->metaType.id(); - QMetaType::destruct(typeId, data); - QMetaType::construct(typeId, data, d()->gadgetPtr()); + QMetaType(typeId).destruct(data); + QMetaType(typeId).construct(data, d()->gadgetPtr()); return true; } @@ -407,9 +407,9 @@ ReturnedValue QQmlValueTypeWrapper::method_toString(const FunctionObject *b, con RETURN_UNDEFINED(); QString result; - if (!QMetaType::convert(w->d()->gadgetPtr(), w->d()->valueType()->metaType.id(), &result, QMetaType::QString)) { - result = QString::fromUtf8(QMetaType::typeName(w->d()->valueType()->metaType.id())) - + QLatin1Char('('); + if (!QMetaType::convert(w->d()->valueType()->metaType, w->d()->gadgetPtr(), + QMetaType(QMetaType::QString), &result)) { + result = QString::fromUtf8(w->d()->valueType()->metaType.name()) + QLatin1Char('('); const QMetaObject *mo = w->d()->propertyCache()->metaObject(); const int propCount = mo->propertyCount(); for (int i = 0; i < propCount; ++i) { diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index b946027b8d..bf8400f526 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -1014,8 +1014,8 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * if (error.isValid()) ep->warning(error); if (a[0]) { - QMetaType::destruct(returnType, a[0]); - QMetaType::construct(returnType, a[0], nullptr); + QMetaType(returnType).destruct(a[0]); + QMetaType(returnType).construct(a[0], nullptr); } } else { if (a[0]) { diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index d0f049039b..6dd12d61d5 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -824,7 +824,7 @@ ReturnedValue formatDateTimeObject(const T &formatThis, const QV4::Scope &scope, auto enginePriv = QQmlEnginePrivate::get(scope.engine->qmlEngine()); auto localeMetaTypeId = qMetaTypeId(); QVariant locale = enginePriv->v4engine()->toVariant(argv[1], localeMetaTypeId); - if (!locale.canConvert(localeMetaTypeId)) + if (!locale.canConvert(QMetaType(localeMetaTypeId))) scope.engine->throwError(QLatin1String("%1(): Bad second argument (must be either string, number or locale)").arg(functionName)); formatted = locale.value().toString(formatThis, formatOptions); } diff --git a/src/qmlmodels/qqmllistaccessor.cpp b/src/qmlmodels/qqmllistaccessor.cpp index 69427df184..21481b8067 100644 --- a/src/qmlmodels/qqmllistaccessor.cpp +++ b/src/qmlmodels/qqmllistaccessor.cpp @@ -82,7 +82,7 @@ void QQmlListAccessor::setList(const QVariant &v, QQmlEngine *engine) m_type = VariantList; } else if (d.userType() == qMetaTypeId>()) { m_type = ObjectList; - } else if (d.canConvert(QMetaType::Int)) { + } else if (d.canConvert(QMetaType(QMetaType::Int))) { // Here we have to check for an upper limit, because down the line code might (well, will) // allocate memory depending on the number of elements. The upper limit cannot be INT_MAX: // QVector> something; diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp index f3a6fea193..71091174bd 100644 --- a/src/qmltest/quicktestresult.cpp +++ b/src/qmltest/quicktestresult.cpp @@ -501,8 +501,10 @@ bool QuickTestResult::verify bool QuickTestResult::fuzzyCompare(const QVariant &actual, const QVariant &expected, qreal delta) { if (actual.userType() == QMetaType::QColor || expected.userType() == QMetaType::QColor) { - if (!actual.canConvert(QMetaType::QColor) || !expected.canConvert(QMetaType::QColor)) + if (!actual.canConvert(QMetaType(QMetaType::QColor)) + || !expected.canConvert(QMetaType(QMetaType::QColor))) { return false; + } //fuzzy color comparison QColor act; diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp index 82d6ca26be..b2fb0a4e1b 100644 --- a/src/quick/util/qquickanimation.cpp +++ b/src/quick/util/qquickanimation.cpp @@ -1965,7 +1965,7 @@ QAbstractAnimationJob* QQuickParallelAnimation::transition(QQuickStateActions &a void QQuickPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) { if (variant.userType() != QMetaType::QString) { - variant.convert(type); + variant.convert(QMetaType(type)); return; } @@ -1985,7 +1985,7 @@ void QQuickPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) break; default: if (QQmlValueTypeFactory::isValueType((uint)type)) { - variant.convert(type); + variant.convert(QMetaType(type)); } else { QQmlMetaType::StringConverter converter = QQmlMetaType::customStringConverter(type); if (converter) -- cgit v1.2.3