Commit 4be818c2 authored by Gus Grubba's avatar Gus Grubba

Merge pull request #3264 from dogmaphobic/fixFlightModesCrash

Fixed crash when switching to the Flight Modes panel.
parents 0d214e1e 08eff3b2
/*===================================================================== /*=====================================================================
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful, QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>. along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/ ======================================================================*/
/// @file /// @file
...@@ -107,8 +107,10 @@ QString FlightModesComponent::prerequisiteSetup(void) const ...@@ -107,8 +107,10 @@ QString FlightModesComponent::prerequisiteSetup(void) const
return plugin->airframeComponent()->name(); return plugin->airframeComponent()->name();
} else if (!plugin->radioComponent()->setupComplete()) { } else if (!plugin->radioComponent()->setupComplete()) {
return plugin->radioComponent()->name(); return plugin->radioComponent()->name();
} else if (!plugin->sensorsComponent()->setupComplete()) {
return plugin->sensorsComponent()->name();
} }
} }
return QString(); return QString();
} }
/*===================================================================== /*=====================================================================
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful, QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>. along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/ ======================================================================*/
#include "PX4AutoPilotPlugin.h" #include "PX4AutoPilotPlugin.h"
...@@ -44,7 +44,7 @@ enum PX4_CUSTOM_MAIN_MODE { ...@@ -44,7 +44,7 @@ enum PX4_CUSTOM_MAIN_MODE {
PX4_CUSTOM_MAIN_MODE_OFFBOARD, PX4_CUSTOM_MAIN_MODE_OFFBOARD,
PX4_CUSTOM_MAIN_MODE_STABILIZED, PX4_CUSTOM_MAIN_MODE_STABILIZED,
PX4_CUSTOM_MAIN_MODE_RATTITUDE PX4_CUSTOM_MAIN_MODE_RATTITUDE
}; };
enum PX4_CUSTOM_SUB_MODE_AUTO { enum PX4_CUSTOM_SUB_MODE_AUTO {
...@@ -80,10 +80,10 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(Vehicle* vehicle, QObject* parent) : ...@@ -80,10 +80,10 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(Vehicle* vehicle, QObject* parent) :
_incorrectParameterVersion(false) _incorrectParameterVersion(false)
{ {
Q_ASSERT(vehicle); Q_ASSERT(vehicle);
_airframeFacts = new PX4AirframeLoader(this, _vehicle->uas(), this); _airframeFacts = new PX4AirframeLoader(this, _vehicle->uas(), this);
Q_CHECK_PTR(_airframeFacts); Q_CHECK_PTR(_airframeFacts);
PX4AirframeLoader::loadAirframeMetaData(); PX4AirframeLoader::loadAirframeMetaData();
} }
...@@ -96,28 +96,28 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void) ...@@ -96,28 +96,28 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void)
{ {
if (_components.count() == 0 && !_incorrectParameterVersion) { if (_components.count() == 0 && !_incorrectParameterVersion) {
Q_ASSERT(_vehicle); Q_ASSERT(_vehicle);
if (parametersReady()) { if (parametersReady()) {
_airframeComponent = new AirframeComponent(_vehicle, this); _airframeComponent = new AirframeComponent(_vehicle, this);
_airframeComponent->setupTriggerSignals(); _airframeComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent)); _components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent));
_radioComponent = new PX4RadioComponent(_vehicle, this); _radioComponent = new PX4RadioComponent(_vehicle, this);
_radioComponent->setupTriggerSignals(); _radioComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_radioComponent)); _components.append(QVariant::fromValue((VehicleComponent*)_radioComponent));
_flightModesComponent = new FlightModesComponent(_vehicle, this);
_flightModesComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_flightModesComponent));
_sensorsComponent = new SensorsComponent(_vehicle, this); _sensorsComponent = new SensorsComponent(_vehicle, this);
_sensorsComponent->setupTriggerSignals(); _sensorsComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_sensorsComponent)); _components.append(QVariant::fromValue((VehicleComponent*)_sensorsComponent));
_flightModesComponent = new FlightModesComponent(_vehicle, this);
_flightModesComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_flightModesComponent));
_powerComponent = new PowerComponent(_vehicle, this); _powerComponent = new PowerComponent(_vehicle, this);
_powerComponent->setupTriggerSignals(); _powerComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_powerComponent)); _components.append(QVariant::fromValue((VehicleComponent*)_powerComponent));
_safetyComponent = new SafetyComponent(_vehicle, this); _safetyComponent = new SafetyComponent(_vehicle, this);
_safetyComponent->setupTriggerSignals(); _safetyComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_safetyComponent)); _components.append(QVariant::fromValue((VehicleComponent*)_safetyComponent));
...@@ -136,7 +136,7 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void) ...@@ -136,7 +136,7 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void)
qWarning() << "Call to vehicleCompenents prior to parametersReady"; qWarning() << "Call to vehicleCompenents prior to parametersReady";
} }
} }
return _components; return _components;
} }
...@@ -150,8 +150,8 @@ void PX4AutoPilotPlugin::_parametersReadyPreChecks(bool missingParameters) ...@@ -150,8 +150,8 @@ void PX4AutoPilotPlugin::_parametersReadyPreChecks(bool missingParameters)
_incorrectParameterVersion = true; _incorrectParameterVersion = true;
qgcApp()->showMessage("This version of GroundControl can only perform vehicle setup on a newer version of firmware. " qgcApp()->showMessage("This version of GroundControl can only perform vehicle setup on a newer version of firmware. "
"Please perform a Firmware Upgrade if you wish to use Vehicle Setup."); "Please perform a Firmware Upgrade if you wish to use Vehicle Setup.");
} }
_parametersReady = true; _parametersReady = true;
_missingParameters = missingParameters; _missingParameters = missingParameters;
emit missingParametersChanged(_missingParameters); emit missingParametersChanged(_missingParameters);
......
/*===================================================================== /*=====================================================================
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful, QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>. along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/ ======================================================================*/
#include "PX4SimpleFlightModesController.h" #include "PX4SimpleFlightModesController.h"
...@@ -53,9 +53,29 @@ void PX4SimpleFlightModesController::_rcChannelsChanged(int channelCount, int pw ...@@ -53,9 +53,29 @@ void PX4SimpleFlightModesController::_rcChannelsChanged(int channelCount, int pw
} }
emit rcChannelValuesChanged(); emit rcChannelValuesChanged();
int flightModeChannel = getParameterFact(-1, "RC_MAP_FLTMODE")->rawValue().toInt() - 1; Fact* pFact = getParameterFact(-1, "RC_MAP_FLTMODE");
if(!pFact) {
#if defined _MSC_VER
qCritical() << "RC_MAP_FLTMODE Fact is NULL in" << __FILE__ << __LINE__;
#else
qCritical() << "RC_MAP_FLTMODE Fact is NULL in" << __func__ << __FILE__ << __LINE__;
#endif
return;
}
int flightModeChannel = pFact->rawValue().toInt() - 1;
pFact = getParameterFact(-1, QString("RC%1_REV").arg(flightModeChannel + 1));
if(!pFact) {
#if defined _MSC_VER
qCritical() << QString("RC%1_REV").arg(flightModeChannel + 1) << "Fact is NULL in" << __FILE__ << __LINE__;
#else
qCritical() << QString("RC%1_REV").arg(flightModeChannel + 1) << " Fact is NULL in" << __func__ << __FILE__ << __LINE__;
#endif
return;
}
int flightModeReversed = getParameterFact(1, QString("RC%1_REV").arg(flightModeChannel + 1))->rawValue().toInt(); int flightModeReversed = pFact->rawValue().toInt();
if (flightModeChannel < 0 || flightModeChannel > channelCount) { if (flightModeChannel < 0 || flightModeChannel > channelCount) {
return; return;
......
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