aboutsummaryrefslogtreecommitdiffstats
path: root/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2020-04-21 08:13:24 +0200
committerThomas Hartmann <thomas.hartmann@qt.io>2020-04-21 09:41:12 +0000
commit970f075e3398fe386083810c4911e50ee0f8bb5a (patch)
tree4208a7501018fb2451ba2084d8f789f7e3c061bc /share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp
parentd8e986abcac84755afbfaffea169fa2c9149ee9c (diff)
QmlDesigner: Show proper error message for component
If a component cannot be created we have to show a proper error message. Task-number: QDS-1980 Change-Id: I48a6ff0fd89c9666328c501abb00dc0997171d96 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp')
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp
index 395b56e241..483cf581c1 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp
@@ -199,6 +199,18 @@ Internal::ObjectNodeInstance::Pointer ServerNodeInstance::createInstance(QObject
return instance;
}
+QString static getErrorString(QQmlEngine *engine, const QString &componentPath)
+{
+ QQmlComponent component(engine, componentPath);
+
+ QObject *o = component.create(nullptr);
+ delete o;
+ QString s;
+ for (const QQmlError &error : component.errors())
+ s.append(error.toString());
+ return s;
+}
+
ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceServer,
const InstanceContainer &instanceContainer,
ComponentWrap componentWrap)
@@ -215,8 +227,11 @@ ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceSe
nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, QLatin1String("Custom parser object could not be created."), instanceContainer.instanceId());
} else if (!instanceContainer.componentPath().isEmpty()) {
object = Internal::ObjectNodeInstance::createComponent(instanceContainer.componentPath(), nodeInstanceServer->context());
- if (object == nullptr)
- nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, QString("Component with path %1 could not be created.").arg(instanceContainer.componentPath()), instanceContainer.instanceId());
+ if (object == nullptr) {
+ const QString errors = getErrorString(nodeInstanceServer->engine(), instanceContainer.componentPath());
+ const QString message = QString("Component with path %1 could not be created.\n\n").arg(instanceContainer.componentPath());
+ nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, message + errors, instanceContainer.instanceId());
+ }
} else {
object = Internal::ObjectNodeInstance::createPrimitive(QString::fromUtf8(instanceContainer.type()), instanceContainer.majorNumber(), instanceContainer.minorNumber(), nodeInstanceServer->context());
if (object == nullptr)