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 <marco.bubke@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Thomas Hartmann
2021-08-05 17:34:35 +02:00
parent e3ac8a79b9
commit d5214b0e45

View File

@@ -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());