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: Alessandro Portale <alessandro.portale@theqtcompany.com>
This commit is contained in:
Thomas Hartmann
2015-02-26 17:30:56 +01:00
committed by Thomas Hartmann
parent 7c192f6490
commit e8c8968ab6
2 changed files with 11 additions and 5 deletions
@@ -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());
}