From 9d90715752106f8cc6a8c75e3c242d66f52e42b9 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 11 Nov 2021 13:50:56 +0100 Subject: [PATCH] QmlDesigner: Refresh items if state is changed We have to paint each item after a state change. This seems to be a regression caused by the swtich to Qt 6. Task-number: QDS-5462 Change-Id: I10a1e0e03c7e887c0998864f397fcbe429364ec7 Reviewed-by: Miikka Heikkinen --- .../instances/qmlstatenodeinstance.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlstatenodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlstatenodeinstance.cpp index 5b320814594..c07cc4bfcff 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlstatenodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlstatenodeinstance.cpp @@ -25,10 +25,11 @@ #include "qmlstatenodeinstance.h" -#include - #include "qmlpropertychangesnodeinstance.h" +#include +#include + namespace QmlDesigner { namespace Internal { @@ -53,12 +54,28 @@ QmlStateNodeInstance::Pointer return instance; } +void setAllNodesDirtyRecursive(QQuickItem *parentItem) +{ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + Q_UNUSED(parentItem) +#else + if (!parentItem) + return; + const QList children = parentItem->childItems(); + for (QQuickItem *childItem : children) + setAllNodesDirtyRecursive(childItem); + DesignerSupport::addDirty(parentItem, QQuickDesignerSupport::Content); +#endif +} + void QmlStateNodeInstance::activateState() { if (!QmlPrivateGate::States::isStateActive(object(), context()) && nodeInstanceServer()->hasInstanceForObject(object())) { nodeInstanceServer()->setStateInstance(nodeInstanceServer()->instanceForObject(object())); QmlPrivateGate::States::activateState(object(), context()); + + setAllNodesDirtyRecursive(nodeInstanceServer()->rootItem()); } }