Commit aa52020c authored by dogmaphobic's avatar dogmaphobic

Fixed crash when switching to the Flight Modes panel.

parent 0d214e1e
......@@ -107,6 +107,8 @@ QString FlightModesComponent::prerequisiteSetup(void) const
return plugin->airframeComponent()->name();
} else if (!plugin->radioComponent()->setupComplete()) {
return plugin->radioComponent()->name();
} else if (!plugin->sensorsComponent()->setupComplete()) {
return plugin->sensorsComponent()->name();
}
}
......
......@@ -106,14 +106,14 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void)
_radioComponent->setupTriggerSignals();
_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->setupTriggerSignals();
_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->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_powerComponent));
......
......@@ -53,9 +53,21 @@ void PX4SimpleFlightModesController::_rcChannelsChanged(int channelCount, int pw
}
emit rcChannelValuesChanged();
int flightModeChannel = getParameterFact(-1, "RC_MAP_FLTMODE")->rawValue().toInt() - 1;
Fact* pFact = getParameterFact(-1, "RC_MAP_FLTMODE");
if(!pFact) {
qCritical() << "RC_MAP_FLTMODE Fact is NULL in" << __func__ << __FILE__ << __LINE__;
return;
}
int flightModeChannel = pFact->rawValue().toInt() - 1;
pFact = getParameterFact(-1, QString("RC%1_REV").arg(flightModeChannel + 1));
if(!pFact) {
qCritical() << QString("RC%1_REV").arg(flightModeChannel + 1) << "is NULL in" << __func__ << __FILE__ << __LINE__;
return;
}
int flightModeReversed = getParameterFact(1, QString("RC%1_REV").arg(flightModeChannel + 1))->rawValue().toInt();
int flightModeReversed = pFact->rawValue().toInt();
if (flightModeChannel < 0 || flightModeChannel > channelCount) {
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