diff --git a/src/QGCQmlWidgetHolder.cpp b/src/QGCQmlWidgetHolder.cpp index 986633c5e0eec7e4972c1412daa7db0c35db1b33..5da881ce4b7891a57bc0eef367c52bf07ce3027c 100644 --- a/src/QGCQmlWidgetHolder.cpp +++ b/src/QGCQmlWidgetHolder.cpp @@ -25,6 +25,7 @@ /// @author Don Gagne #include "QGCQmlWidgetHolder.h" +#include "QGCMessageBox.h" QGCQmlWidgetHolder::QGCQmlWidgetHolder(QWidget *parent) : QWidget(parent) @@ -43,8 +44,19 @@ void QGCQmlWidgetHolder::setAutoPilot(AutoPilotPlugin* autoPilot) _ui.qmlWidget->rootContext()->setContextProperty("autopilot", autoPilot); } -void QGCQmlWidgetHolder::setSource(const QUrl& qmlUrl) +bool QGCQmlWidgetHolder::setSource(const QUrl& qmlUrl) { _ui.qmlWidget->setSource(qmlUrl); - _ui.qmlWidget->setMinimumSize(_ui.qmlWidget->rootObject()->width(), _ui.qmlWidget->rootObject()->height()); + if (_ui.qmlWidget->status() != QQuickWidget::Ready) { + QString errorList; + + foreach (QQmlError error, _ui.qmlWidget->errors()) { + errorList += error.toString(); + errorList += "\n"; + } + QGCMessageBox::warning(tr("Qml Error"), tr("Source not ready: %1\nErrors:\n%2").arg(_ui.qmlWidget->status()).arg(errorList)); + return false; + } + + return true; } diff --git a/src/QGCQmlWidgetHolder.h b/src/QGCQmlWidgetHolder.h index 90b8e084c53c743cf0fe25759640a0c2ee6be1b4..0cfb8a9996f17a4c685658bd3a388f6939c2ac1b 100644 --- a/src/QGCQmlWidgetHolder.h +++ b/src/QGCQmlWidgetHolder.h @@ -50,7 +50,7 @@ public: void setAutoPilot(AutoPilotPlugin* autoPilot); /// Sets the QML into the control - void setSource(const QUrl& qmlUrl); + bool setSource(const QUrl& qmlUrl); private: Ui::QGCQmlWidgetHolder _ui;