aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlpropertyvalidator.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-01-30 16:37:37 +0100
committerUlf Hermann <ulf.hermann@qt.io>2023-02-24 09:42:23 +0100
commita09ea6b3d6265a98c17e190db007fecfbd76f317 (patch)
tree5886c0877aa7b3b33e7685a2c043390be73e9a23 /src/qml/qml/qqmlpropertyvalidator.cpp
parent499acf3114c973c5387331cab36a0b7038423cfd (diff)
Avoid duplicate value type creation
We can actually produce an uninitialized but pre-allocated QVariant using QVariant::Private. Using the new in-place construction support in QMetaObject, we can minimize the amount of copying necessary for value types. Fixes: QTBUG-108789 Change-Id: I6b748794a6adbf6558e1e3086eab80fcfb3154a0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlpropertyvalidator.cpp')
-rw-r--r--src/qml/qml/qqmlpropertyvalidator.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlpropertyvalidator.cpp b/src/qml/qml/qqmlpropertyvalidator.cpp
index c6783842dc..308b66e2d9 100644
--- a/src/qml/qml/qqmlpropertyvalidator.cpp
+++ b/src/qml/qml/qqmlpropertyvalidator.cpp
@@ -568,10 +568,10 @@ QQmlError QQmlPropertyValidator::validateLiteralBinding(
default: return QString();
}
};
- QVariant result(property->propType());
- if (!QQmlValueTypeProvider::createValueType(
+ const QVariant result = QQmlValueTypeProvider::createValueType(
compilationUnit->bindingValueAsString(binding),
- result.metaType(), result.data())) {
+ property->propType());
+ if (!result.isValid()) {
return warnOrError(tr("Invalid property assignment: %1 expected")
.arg(typeName()));
}