From ac0697780e90c292c370f278b1c800d99540c148 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 13 Apr 2022 16:08:40 +0200 Subject: [PATCH] QmlDesigner: Only allow goIntoComponent for existing ones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skip the ones from Qt. Change-Id: I4eae715b87948e8d47be8919d6b3356864fb0bd7 Reviewed-by: Reviewed-by: Henning Gründl --- .../modelnodecontextmenu_helper.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp index b7a68890b82..975a59d478d 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp +++ b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp @@ -33,6 +33,8 @@ #include #include +#include + namespace QmlDesigner { static inline bool itemsHaveSameParent(const QList &siblingList) @@ -94,10 +96,24 @@ bool selectionHasSameParent(const SelectionContext &selectionState) return !selectionState.selectedModelNodes().isEmpty() && itemsHaveSameParent(selectionState.selectedModelNodes()); } +bool fileComponentExists(const ModelNode &modelNode) +{ + if (!modelNode.metaInfo().isFileComponent()) + return true; + + const QString fileName = modelNode.metaInfo().componentFileName(); + + if (fileName.contains("qml/QtQuick")) + return false; + + return QFile::exists(fileName); +} + bool selectionIsComponent(const SelectionContext &selectionState) { return selectionState.currentSingleSelectedNode().isValid() - && selectionState.currentSingleSelectedNode().isComponent(); + && selectionState.currentSingleSelectedNode().isComponent() + && fileComponentExists(selectionState.currentSingleSelectedNode()); } bool selectionIsImported3DAsset(const SelectionContext &selectionState)