From 3ba7471b884f4d94a08ebb2682d44b09e6c4f584 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Sat, 24 May 2025 14:20:00 +0200 Subject: [PATCH] QmlDesigner: Remove double evaluation That calls are quite expesive. So there is no need to call them twice. Change-Id: I4ef2f17693464573b7614a529038b0e06f887f49 Reviewed-by: Thomas Hartmann --- .../propertyeditor/propertyeditorvalue.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp index e2d5910820f..8b9b2fe6e71 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp @@ -72,9 +72,9 @@ static bool cleverColorCompare(const QVariant &value1, const QVariant &value2) // "red" is the same color as "#ff0000" // To simplify editing we convert all explicit color names in the hash format -static void fixAmbigousColorNames(const ModelNode &modelNode, PropertyNameView name, QVariant *value) +static void fixAmbigousColorNames(const NodeMetaInfo &metaInfo, QVariant *value) { - if (auto metaInfo = modelNode.metaInfo(); metaInfo.property(name).propertyType().isColor()) { + if (metaInfo.isColor()) { if (value->typeId() == QMetaType::QColor) { QColor color = value->value(); int alpha = color.alpha(); @@ -87,9 +87,9 @@ static void fixAmbigousColorNames(const ModelNode &modelNode, PropertyNameView n } } -static void fixUrl(const ModelNode &modelNode, PropertyNameView name, QVariant *value) +static void fixUrl(const NodeMetaInfo &metaInfo, QVariant *value) { - if (auto metaInfo = modelNode.metaInfo(); metaInfo.property(name).propertyType().isUrl()) { + if (metaInfo.isUrl()) { if (!value->isValid()) *value = QStringLiteral(""); } @@ -132,8 +132,9 @@ void PropertyEditorValue::setValue(const QVariant &value) if (!compareVariants(m_value, value) && !cleverDoubleCompare(value, m_value) && !colorsEqual) m_value = value; - fixAmbigousColorNames(modelNode(), name(), &m_value); - fixUrl(modelNode(), name(), &m_value); + auto propertyTypeMetaInfo = modelNode().metaInfo().property(name()).propertyType(); + fixAmbigousColorNames(propertyTypeMetaInfo, &m_value); + fixUrl(propertyTypeMetaInfo, &m_value); if (!colorsEqual) emit valueChangedQml();