Commit e8c8968a authored by Thomas Hartmann's avatar Thomas Hartmann Committed by Thomas Hartmann

QmlDesigner.QmlPuppet: Show import error messages on root item

* If an import fails we show this as an error on the root item.
* If all imports fail (including the QtQuick import) we also
  show an error message, but try to recover using QtQuick 2.0.

Change-Id: Ibfece2acdb9f2a6ba26dfd9b31607507fec82dd1
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@theqtcompany.com>
parent 7c192f64
......@@ -420,11 +420,8 @@ void NodeInstanceServer::setupImports(const QVector<AddImportContainer> &contain
workingImportStatementList.prepend(firstWorkingImportStatement);
}
QVector<qint32> instanceIds;
foreach (const IdContainer &idContainer, idContainerVector)
instanceIds.append(idContainer.instanceId());
if (!errorMessage.isEmpty())
sendDebugOutput(DebugOutputCommand::WarningType, errorMessage, instanceIds);
sendDebugOutput(DebugOutputCommand::WarningType, errorMessage);
setupOnlyWorkingImports(workingImportStatementList);
}
......@@ -438,6 +435,15 @@ void NodeInstanceServer::setupOnlyWorkingImports(const QStringList &workingImpor
m_importComponent->setData(componentCode.append("\nItem {}\n"), fileUrl());
m_importComponentObject = m_importComponent->create();
if (!m_importComponentObject) {
delete m_importComponent;
m_importComponent = new QQmlComponent(engine(), quickView());
m_importComponent->setData("import QtQuick 2.0\n\nItem {}\n", fileUrl());
sendDebugOutput(DebugOutputCommand::WarningType, tr("No working QtQuick import"));
m_importComponentObject = m_importComponent->create();
}
Q_ASSERT(m_importComponent && m_importComponentObject);
Q_ASSERT_X(m_importComponent->errors().isEmpty(), __FUNCTION__, m_importComponent->errorString().toLatin1());
}
......
......@@ -128,7 +128,7 @@ public:
virtual QQmlView *declarativeView() const = 0;
virtual QQuickView *quickView() const = 0;
void sendDebugOutput(DebugOutputCommand::Type type, const QString &message, qint32 instanceId);
void sendDebugOutput(DebugOutputCommand::Type type, const QString &message, qint32 instanceId = 0);
void sendDebugOutput(DebugOutputCommand::Type type, const QString &message, const QVector<qint32> &instanceIds);
void removeInstanceRelationsipForDeletedObject(QObject *object);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment