From d5214b0e45c7186169f30b8b97e961f171b08f90 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 5 Aug 2021 17:34:35 +0200 Subject: [PATCH] QmlDesigner: Do not create components from componentPath in importPaths If the component comes from the import paths we should not create the component directly. This can have subtle unwanted side effects. Styling for example is not working with Qt 6. Change-Id: Ia4f33b46d3dc427ac95838f2ca73a880639d600a Reviewed-by: Marco Bubke Reviewed-by: Qt CI Bot --- .../qml2puppet/instances/servernodeinstance.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp index f53e31b49f2..51e4ef2ff5f 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp @@ -219,6 +219,13 @@ QString static getErrorString(QQmlEngine *engine, const QString &componentPath) return s; } +bool isInPathList(const QStringList &pathList, const QString &componentPath) +{ + return std::any_of(pathList.begin(), pathList.end(), [&](auto &&path) { + return componentPath.startsWith(path); + }); +} + ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceServer, const InstanceContainer &instanceContainer, ComponentWrap componentWrap) @@ -233,7 +240,9 @@ ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceSe object = Internal::ObjectNodeInstance::createCustomParserObject(instanceContainer.nodeSource(), nodeInstanceServer->importCode(), nodeInstanceServer->context()); if (object == nullptr) nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, QLatin1String("Custom parser object could not be created."), instanceContainer.instanceId()); - } else if (!instanceContainer.componentPath().isEmpty()) { + } else if (!instanceContainer.componentPath().isEmpty() + && !isInPathList(nodeInstanceServer->engine()->importPathList(), + instanceContainer.componentPath())) { object = Internal::ObjectNodeInstance::createComponent(instanceContainer.componentPath(), nodeInstanceServer->context()); if (object == nullptr) { object = Internal::ObjectNodeInstance::createPrimitive(QString::fromUtf8(instanceContainer.type()), instanceContainer.majorNumber(), instanceContainer.minorNumber(), nodeInstanceServer->context());