QmlDesigner: Fix bound properties change behavior

Changing a bound property was triggering a value change twice. Once with
the previous value and another time with the newly set value. This was
solved by locking the binding property change emit with a scope lock.

Change-Id: I9605269e911f0468b2d52d74ad8a2a43f907a18c
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Henning Gruendl
2022-05-17 15:17:06 +02:00
committed by Henning Gründl
parent 87a7d94629
commit e865b03448

View File

@@ -256,6 +256,9 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
if (noValidSelection()) if (noValidSelection())
return; return;
QScopeGuard unlock([&](){ m_locked = false; });
m_locked = true;
executeInTransaction("PropertyEditorView::changeExpression", [this, name](){ executeInTransaction("PropertyEditorView::changeExpression", [this, name](){
PropertyName underscoreName(name); PropertyName underscoreName(name);
underscoreName.replace('.', '_'); underscoreName.replace('.', '_');
@@ -317,9 +320,9 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
return; return;
} }
if (qmlObjectNode->expression(name) != value->expression() || !qmlObjectNode->propertyAffectedByCurrentState(name)) if (qmlObjectNode->expression(name) != value->expression()
|| !qmlObjectNode->propertyAffectedByCurrentState(name))
qmlObjectNode->setBindingProperty(name, value->expression()); qmlObjectNode->setBindingProperty(name, value->expression());
}); /* end of transaction */ }); /* end of transaction */
} }
@@ -692,6 +695,9 @@ void PropertyEditorView::variantPropertiesChanged(const QList<VariantProperty>&
void PropertyEditorView::bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags /*propertyChange*/) void PropertyEditorView::bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags /*propertyChange*/)
{ {
if (locked())
return;
if (noValidSelection()) if (noValidSelection())
return; return;