Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
69cc3141
Commit
69cc3141
authored
Feb 22, 2015
by
Don Gagne
Browse files
Move error handling to correct location
parent
644ac77f
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/QGCQmlWidgetHolder.cpp
View file @
69cc3141
...
...
@@ -25,7 +25,6 @@
/// @author Don Gagne <don@thegagnes.com>
#include
"QGCQmlWidgetHolder.h"
#include
"QGCMessageBox.h"
QGCQmlWidgetHolder
::
QGCQmlWidgetHolder
(
QWidget
*
parent
)
:
QWidget
(
parent
)
...
...
@@ -46,17 +45,5 @@ void QGCQmlWidgetHolder::setAutoPilot(AutoPilotPlugin* autoPilot)
bool
QGCQmlWidgetHolder
::
setSource
(
const
QUrl
&
qmlUrl
)
{
_ui
.
qmlWidget
->
setSource
(
qmlUrl
);
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
\n
Errors:
\n
%2"
).
arg
(
_ui
.
qmlWidget
->
status
()).
arg
(
errorList
));
return
false
;
}
return
true
;
return
_ui
.
qmlWidget
->
setSource
(
qmlUrl
);
}
src/QGCQmlWidgetHolder.h
View file @
69cc3141
...
...
@@ -49,7 +49,8 @@ public:
/// Sets the UAS into the widget which in turn will load facts into the context
void
setAutoPilot
(
AutoPilotPlugin
*
autoPilot
);
/// Sets the QML into the control
/// Sets the QML into the control. Will display errors message box if error occurs loading source.
/// @return true: source loaded, false: source not loaded, errors occured
bool
setSource
(
const
QUrl
&
qmlUrl
);
private:
...
...
src/QGCQuickWidget.cc
View file @
69cc3141
...
...
@@ -23,6 +23,7 @@
#include
"QGCQuickWidget.h"
#include
"AutoPilotPluginManager.h"
#include
"QGCMessageBox.h"
#include
<QQmlContext>
#include
<QQmlEngine>
...
...
@@ -43,3 +44,20 @@ void QGCQuickWidget::setAutoPilot(AutoPilotPlugin* autoPilot)
{
rootContext
()
->
setContextProperty
(
"autopilot"
,
autoPilot
);
}
bool
QGCQuickWidget
::
setSource
(
const
QUrl
&
qmlUrl
)
{
QQuickWidget
::
setSource
(
qmlUrl
);
if
(
status
()
!=
Ready
)
{
QString
errorList
;
foreach
(
QQmlError
error
,
errors
())
{
errorList
+=
error
.
toString
();
errorList
+=
"
\n
"
;
}
QGCMessageBox
::
warning
(
tr
(
"Qml Error"
),
tr
(
"Source not ready: Status(%1)
\n
Errors:
\n
%2"
).
arg
(
status
()).
arg
(
errorList
));
return
false
;
}
return
true
;
}
src/QGCQuickWidget.h
View file @
69cc3141
...
...
@@ -42,6 +42,10 @@ public:
/// Sets the UAS into the widget which in turn will load facts into the context
void
setAutoPilot
(
AutoPilotPlugin
*
autoPilot
);
/// Sets the QML into the control. Will display errors message box if error occurs loading source.
/// @return true: source loaded, false: source not loaded, errors occured
bool
setSource
(
const
QUrl
&
qmlUrl
);
};
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment