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
......@@ -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,29 @@ 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) {
#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) {
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