diff options
author | Vikas Pachdha <vikas.pachdha@qt.io> | 2020-08-31 11:08:41 +0200 |
---|---|---|
committer | Vikas Pachdha <vikas.pachdha@qt.io> | 2020-09-01 11:07:16 +0000 |
commit | 4473769bc466d62d5ac9bb26e813c513513ccfb2 (patch) | |
tree | 84c86865c4d6fc064c76d210dd63ded1a84487ff | |
parent | f43b81ae6f0be61b492e07fc306b7a2dc8a2ef3d (diff) |
AssetExport: Notify QML parsing errors
QML can not be exported if the document have parsing errors
Task-number: QDS-2667
Change-Id: I22075789cfa5853b1607c45e2b49bb761836c0d6
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
-rw-r--r-- | src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp b/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp index b975c228e6..bef733b27b 100644 --- a/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp +++ b/src/plugins/qmldesigner/assetexporterplugin/assetexporter.cpp @@ -26,6 +26,8 @@ #include "componentexporter.h" #include "exportnotification.h" +#include "designdocument.h" +#include "qmldesignerplugin.h" #include "rewriterview.h" #include "qmlitemnode.h" #include "qmlobjectnode.h" @@ -163,7 +165,6 @@ void AssetExporter::exportComponent(const ModelNode &rootNode) Component exporter(*this, rootNode); exporter.exportComponent(); m_components.append(exporter.json()); - notifyProgress((m_totalFileCount - m_exportFiles.count()) * 0.8 / m_totalFileCount); } void AssetExporter::notifyLoadError(AssetExporterView::LoadState state) @@ -192,12 +193,22 @@ void AssetExporter::onQmlFileLoaded() { QTC_ASSERT(m_view && m_view->model(), qCDebug(loggerError) << "Null model"; return); qCDebug(loggerInfo) << "Qml file load done" << m_view->model()->fileUrl(); - exportComponent(m_view->rootModelNode()); - QString error; - if (!m_view->saveQmlFile(&error)) { - ExportNotification::addError(tr("Error saving QML file. %1") - .arg(error.isEmpty()? tr("Unknown") : error)); + + QmlDesigner::DesignDocument *designDocument = QmlDesigner::QmlDesignerPlugin::instance() + ->documentManager() + .currentDesignDocument(); + if (designDocument->hasQmlParseErrors()) { + ExportNotification::addError(tr("Cannot export QML. Document \"%1\" have parsing errors.") + .arg(designDocument->displayName())); + } else { + exportComponent(m_view->rootModelNode()); + QString error; + if (!m_view->saveQmlFile(&error)) { + ExportNotification::addError(tr("Error saving QML file. %1") + .arg(error.isEmpty()? tr("Unknown") : error)); + } } + notifyProgress((m_totalFileCount - m_exportFiles.count()) * 0.8 / m_totalFileCount); triggerLoadNextFile(); } |