aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlobjectcreator.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-09-18 15:27:24 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-09-23 14:54:47 +0200
commitad6d92d1bd2cd90cf8164fd445ad76432314bfab (patch)
tree17ec3753e9a77c5ff72c7115db12f17707d07f05 /src/qml/qml/qqmlobjectcreator.cpp
parent548124fd008501d027f1aeb1fb9de03de233b320 (diff)
Eliminate QQmlValueTypeProvider::createFromString
It can be expressed as a special case of create() with a QJSValue. Change-Id: I7342026ad694077d2780dd8a852714fa72dd68d0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator.cpp')
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp53
1 files changed, 8 insertions, 45 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index dc720349a1..310f8579bf 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -564,55 +564,18 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
property->writeProperty(_qobject, &value, propertyWriteFlags);
}
break;
- case QMetaType::QVector2D: {
- struct {
- float xp;
- float yp;
- } vec;
- bool ok = QQmlStringConverters::createFromString(QMetaType::QVector2D, compilationUnit->bindingValueAsString(binding), &vec, sizeof(vec));
- assertOrNull(ok);
- Q_UNUSED(ok);
- property->writeProperty(_qobject, &vec, propertyWriteFlags);
- }
- break;
- case QMetaType::QVector3D: {
- struct {
- float xp;
- float yp;
- float zy;
- } vec;
- bool ok = QQmlStringConverters::createFromString(QMetaType::QVector3D, compilationUnit->bindingValueAsString(binding), &vec, sizeof(vec));
- assertOrNull(ok);
- Q_UNUSED(ok);
- property->writeProperty(_qobject, &vec, propertyWriteFlags);
- }
- break;
- case QMetaType::QVector4D: {
- struct {
- float xp;
- float yp;
- float zy;
- float wp;
- } vec;
- bool ok = QQmlStringConverters::createFromString(QMetaType::QVector4D, compilationUnit->bindingValueAsString(binding), &vec, sizeof(vec));
- assertOrNull(ok);
- Q_UNUSED(ok);
- property->writeProperty(_qobject, &vec, propertyWriteFlags);
- }
- break;
+ case QMetaType::QVector2D:
+ case QMetaType::QVector3D:
+ case QMetaType::QVector4D:
case QMetaType::QQuaternion: {
- struct {
- float wp;
- float xp;
- float yp;
- float zp;
- } vec;
- bool ok = QQmlStringConverters::createFromString(QMetaType::QQuaternion, compilationUnit->bindingValueAsString(binding), &vec, sizeof(vec));
+ QVariant result;
+ bool ok = QQml_valueTypeProvider()->createValueFromString(
+ propertyType, compilationUnit->bindingValueAsString(binding), &result);
assertOrNull(ok);
Q_UNUSED(ok);
- property->writeProperty(_qobject, &vec, propertyWriteFlags);
+ property->writeProperty(_qobject, result.data(), propertyWriteFlags);
+ break;
}
- break;
default: {
// generate single literal value assignment to a list property if required
if (property->propType() == qMetaTypeId<QList<qreal> >()) {