From 62d86837e9a20db22b425fb1efc3b3e1c76cefe8 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Fri, 25 Nov 2022 15:44:32 +0100 Subject: [PATCH] QmlDesigner: Fix states editor none visual items When using any none visual item as root (e.g. Window) which don't have a state property the support for adding a state on the root item needs to be deactivated otherwise QtDS is crashing. The new states editor was missing that. On the other hand the use of StatesGroup with none visual items is supported. Change-Id: I194913719a13099ce8ac7cde5f78083ef84dc37f Reviewed-by: Reviewed-by: Thomas Hartmann --- share/qtcreator/qmldesigner/newstateseditor/Main.qml | 1 + .../components/stateseditornew/stateseditorview.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/share/qtcreator/qmldesigner/newstateseditor/Main.qml b/share/qtcreator/qmldesigner/newstateseditor/Main.qml index 92bf99b86c8..7f20190322a 100644 --- a/share/qtcreator/qmldesigner/newstateseditor/Main.qml +++ b/share/qtcreator/qmldesigner/newstateseditor/Main.qml @@ -863,6 +863,7 @@ Rectangle { Item { id: addWrapper + visible: canAddNewStates Canvas { id: addCanvas diff --git a/src/plugins/qmldesigner/components/stateseditornew/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditornew/stateseditorview.cpp index e20f5df7b47..c263a510966 100644 --- a/src/plugins/qmldesigner/components/stateseditornew/stateseditorview.cpp +++ b/src/plugins/qmldesigner/components/stateseditornew/stateseditorview.cpp @@ -105,6 +105,8 @@ void StatesEditorView::setActiveStatesGroupNode(const ModelNode &modelNode) m_activeStatesGroupNode = modelNode; resetModel(); + checkForStatesAvailability(); + emit m_statesEditorModel->activeStateGroupChanged(); emit m_statesEditorModel->activeStateGroupIndexChanged(); } @@ -430,8 +432,10 @@ void StatesEditorView::resetStateGroups() void StatesEditorView::checkForStatesAvailability() { if (m_statesEditorWidget) { - const bool isVisual = QmlVisualNode::isValidQmlVisualNode(activeStatesGroupNode()); - m_statesEditorWidget->showAddNewStatesButton(isVisual); + const bool isVisual = activeStatesGroupNode().metaInfo().isBasedOn( + model()->qtQuickItemMetaInfo(), model()->qtQuick3DNodeMetaInfo()); + const bool isRoot = activeStatesGroupNode().isRootNode(); + m_statesEditorWidget->showAddNewStatesButton(isVisual || !isRoot); } }