From 78ce13e6882e7d574301dbf8a6542f8fda2dc88c Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 20 Jan 2023 16:51:31 +0100 Subject: [PATCH] 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: Reviewed-by: Miikka Heikkinen --- .../instances/qmlpropertychangesnodeinstance.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/tools/qml2puppet/qml2puppet/instances/qmlpropertychangesnodeinstance.cpp b/src/tools/qml2puppet/qml2puppet/instances/qmlpropertychangesnodeinstance.cpp index e836cd49a30..e3538320132 100644 --- a/src/tools/qml2puppet/qml2puppet/instances/qmlpropertychangesnodeinstance.cpp +++ b/src/tools/qml2puppet/qml2puppet/instances/qmlpropertychangesnodeinstance.cpp @@ -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(); } }