forked from qt-creator/qt-creator
QmlDesigner: Only create components as primitives if actually possible
The type might not actually be exported and imported as a folder import. Change-Id: I0ada27d619727044c2f8b8a601a2632a44c5a7cb Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
committed by
Thomas Hartmann
parent
7e9f955a58
commit
8b45f1f6c5
@@ -234,6 +234,25 @@ bool isInPathList(const QStringList &pathList, const QString &componentPath)
|
||||
});
|
||||
}
|
||||
|
||||
bool canBeCreatedAsPrimitive(const QStringList &pathList,
|
||||
const InstanceContainer &instanceContainer,
|
||||
QQmlContext *context,
|
||||
QObject *&object)
|
||||
{
|
||||
if (isInPathList(pathList, instanceContainer.componentPath())) {
|
||||
object = Internal::ObjectNodeInstance::createPrimitive(QString::fromUtf8(
|
||||
instanceContainer.type()),
|
||||
instanceContainer.majorNumber(),
|
||||
instanceContainer.minorNumber(),
|
||||
context);
|
||||
|
||||
if (object)
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceServer,
|
||||
const InstanceContainer &instanceContainer,
|
||||
ComponentWrap componentWrap)
|
||||
@@ -249,8 +268,8 @@ ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceSe
|
||||
if (object == nullptr)
|
||||
nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, QLatin1String("Custom parser object could not be created."), instanceContainer.instanceId());
|
||||
} else if (!instanceContainer.componentPath().isEmpty()
|
||||
&& !isInPathList(nodeInstanceServer->engine()->importPathList(),
|
||||
instanceContainer.componentPath())) {
|
||||
&& !canBeCreatedAsPrimitive(nodeInstanceServer->engine()->importPathList(),
|
||||
instanceContainer, nodeInstanceServer->context(), object)) {
|
||||
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());
|
||||
@@ -260,7 +279,7 @@ ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceSe
|
||||
nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, message + errors, instanceContainer.instanceId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (!object) {
|
||||
object = Internal::ObjectNodeInstance::createPrimitive(QString::fromUtf8(instanceContainer.type()), instanceContainer.majorNumber(), instanceContainer.minorNumber(), nodeInstanceServer->context());
|
||||
if (object == nullptr)
|
||||
nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, QLatin1String("Item could not be created."), instanceContainer.instanceId());
|
||||
|
Reference in New Issue
Block a user