QmlDesigner: Switch to basestate before setting expression in state

When setting an expression in a state then the revert list is not properly
managed. Therefore we have to temporarily enter the basestate
to set the expression.


Task-number: QDS-7801
Change-Id: I4f653e83db4a2d05b1cc0b67d22581cee84557ff
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Thomas Hartmann
2023-01-20 16:51:31 +01:00
parent b40be0f8f5
commit 78ce13e688

View File

@@ -50,7 +50,20 @@ void QmlPropertyChangesNodeInstance::setPropertyBinding(const PropertyName &name
if (QmlPrivateGate::PropertyChanges::isNormalProperty(name)) { // 'restoreEntryValues', 'explicit'
ObjectNodeInstance::setPropertyBinding(name, expression);
} else {
QObject *state = QmlPrivateGate::PropertyChanges::stateObject(object());
ServerNodeInstance activeState = nodeInstanceServer()->activeStateInstance();
auto activeStateInstance = activeState.internalInstance();
const bool inState = activeStateInstance && activeStateInstance->object() == state;
if (inState)
activeState.deactivateState();
QmlPrivateGate::PropertyChanges::changeExpression(object(), name, expression);
if (inState)
activeState.activateState();
}
}