From c14ec1b4c1e54cc2b9a26b52c72d3649cb3f2d07 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 31 Jan 2023 14:08:16 +0200 Subject: [PATCH] QmlDesigner: Don't create material library node in in-file component While there are some valid use cases for having a material library inside in-file component, having duplicate material library nodes in a single file causes some issues that are not trivial to solve, so for now we just prevent this from happening. Fixes: QDS-8656 Change-Id: I4495ea4d972eab76ca444d18ab4c45b403805ad7 Reviewed-by: Mahmoud Badri Reviewed-by: Qt CI Bot --- .../components/materialeditor/materialeditorview.cpp | 5 ++++- .../components/textureeditor/textureeditorview.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp b/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp index b981c82d8fc..ae1049c9e78 100644 --- a/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp +++ b/src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -60,7 +61,9 @@ MaterialEditorView::MaterialEditorView(ExternalDependenciesInterface &externalDe m_ensureMatLibTimer.callOnTimeout([this] { if (model() && model()->rewriterView() && !model()->rewriterView()->hasIncompleteTypeInformation() && model()->rewriterView()->errors().isEmpty()) { - ensureMaterialLibraryNode(); + DesignDocument *doc = QmlDesignerPlugin::instance()->currentDesignDocument(); + if (doc && !doc->inFileComponentModelActive()) + ensureMaterialLibraryNode(); if (m_qmlBackEnd && m_qmlBackEnd->contextObject()) m_qmlBackEnd->contextObject()->setHasMaterialLibrary(materialLibraryNode().isValid()); m_ensureMatLibTimer.stop(); diff --git a/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp b/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp index 47a1d370a0b..07e381fb131 100644 --- a/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp +++ b/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -62,7 +63,9 @@ TextureEditorView::TextureEditorView(AsynchronousImageCache &imageCache, m_ensureMatLibTimer.callOnTimeout([this] { if (model() && model()->rewriterView() && !model()->rewriterView()->hasIncompleteTypeInformation() && model()->rewriterView()->errors().isEmpty()) { - ensureMaterialLibraryNode(); + DesignDocument *doc = QmlDesignerPlugin::instance()->currentDesignDocument(); + if (doc && !doc->inFileComponentModelActive()) + ensureMaterialLibraryNode(); if (m_qmlBackEnd && m_qmlBackEnd->contextObject()) m_qmlBackEnd->contextObject()->setHasMaterialLibrary(materialLibraryNode().isValid()); m_ensureMatLibTimer.stop();