Commit c8942215 authored by Don Gagne's avatar Don Gagne

Work correctly when no Vehicle

parent 3d9a4ce4
...@@ -33,19 +33,18 @@ ...@@ -33,19 +33,18 @@
QGC_LOGGING_CATEGORY(FactPanelControllerLog, "FactPanelControllerLog") QGC_LOGGING_CATEGORY(FactPanelControllerLog, "FactPanelControllerLog")
FactPanelController::FactPanelController(void) : FactPanelController::FactPanelController(void)
_factPanel(NULL) : _vehicle(NULL)
, _uas(NULL)
, _autopilot(NULL)
, _factPanel(NULL)
{ {
_vehicle = qgcApp()->toolbox()->multiVehicleManager()->activeVehicle(); _vehicle = qgcApp()->toolbox()->multiVehicleManager()->activeVehicle();
Q_ASSERT(_vehicle);
if (_vehicle) {
_uas = _vehicle->uas(); _uas = _vehicle->uas();
Q_ASSERT(_uas);
_autopilot = _vehicle->autopilotPlugin(); _autopilot = _vehicle->autopilotPlugin();
Q_ASSERT(_autopilot); }
Q_ASSERT(_autopilot->parametersReady());
Q_ASSERT(!_autopilot->missingParameters());
// Do a delayed check for the _factPanel finally being set correctly from Qml // Do a delayed check for the _factPanel finally being set correctly from Qml
QTimer::singleShot(1000, this, &FactPanelController::_checkForMissingFactPanel); QTimer::singleShot(1000, this, &FactPanelController::_checkForMissingFactPanel);
...@@ -114,7 +113,7 @@ bool FactPanelController::_allParametersExists(int componentId, QStringList name ...@@ -114,7 +113,7 @@ bool FactPanelController::_allParametersExists(int componentId, QStringList name
bool noMissingFacts = true; bool noMissingFacts = true;
foreach (QString name, names) { foreach (QString name, names) {
if (!_autopilot->parameterExists(componentId, name)) { if (_autopilot && !_autopilot->parameterExists(componentId, name)) {
_reportMissingParameter(componentId, name); _reportMissingParameter(componentId, name);
noMissingFacts = false; noMissingFacts = false;
} }
...@@ -132,7 +131,7 @@ void FactPanelController::_checkForMissingFactPanel(void) ...@@ -132,7 +131,7 @@ void FactPanelController::_checkForMissingFactPanel(void)
Fact* FactPanelController::getParameterFact(int componentId, const QString& name) Fact* FactPanelController::getParameterFact(int componentId, const QString& name)
{ {
if (_autopilot->parameterExists(componentId, name)) { if (_autopilot && _autopilot->parameterExists(componentId, name)) {
Fact* fact = _autopilot->getParameterFact(componentId, name); Fact* fact = _autopilot->getParameterFact(componentId, name);
QQmlEngine::setObjectOwnership(fact, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership(fact, QQmlEngine::CppOwnership);
return fact; return fact;
...@@ -144,7 +143,7 @@ Fact* FactPanelController::getParameterFact(int componentId, const QString& name ...@@ -144,7 +143,7 @@ Fact* FactPanelController::getParameterFact(int componentId, const QString& name
bool FactPanelController::parameterExists(int componentId, const QString& name) bool FactPanelController::parameterExists(int componentId, const QString& name)
{ {
return _autopilot->parameterExists(componentId, name); return _autopilot ? _autopilot->parameterExists(componentId, name) : false;
} }
void FactPanelController::_showInternalError(const QString& errorMsg) void FactPanelController::_showInternalError(const QString& errorMsg)
......
...@@ -34,11 +34,13 @@ ...@@ -34,11 +34,13 @@
/// @Brief Constructs a new ParameterEditorController Widget. This widget is used within the PX4VehicleConfig set of screens. /// @Brief Constructs a new ParameterEditorController Widget. This widget is used within the PX4VehicleConfig set of screens.
ParameterEditorController::ParameterEditorController(void) ParameterEditorController::ParameterEditorController(void)
{ {
if (_autopilot) {
const QMap<int, QMap<QString, QStringList> >& groupMap = _autopilot->getGroupMap(); const QMap<int, QMap<QString, QStringList> >& groupMap = _autopilot->getGroupMap();
foreach (int componentId, groupMap.keys()) { foreach (int componentId, groupMap.keys()) {
_componentIds += QString("%1").arg(componentId); _componentIds += QString("%1").arg(componentId);
} }
}
} }
ParameterEditorController::~ParameterEditorController() ParameterEditorController::~ParameterEditorController()
......
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