Browse Source

Merge pull request #3264 from dogmaphobic/fixFlightModesCrash

Fixed crash when switching to the Flight Modes panel.
QGC4.4
Gus Grubba 9 years ago
parent
commit
4be818c240
  1. 2
      src/AutoPilotPlugins/PX4/FlightModesComponent.cc
  2. 10
      src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc
  3. 24
      src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc

2
src/AutoPilotPlugins/PX4/FlightModesComponent.cc

@ -107,6 +107,8 @@ QString FlightModesComponent::prerequisiteSetup(void) const @@ -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();
}
}

10
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc

@ -106,14 +106,14 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void) @@ -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));
@ -150,7 +150,7 @@ void PX4AutoPilotPlugin::_parametersReadyPreChecks(bool missingParameters) @@ -150,7 +150,7 @@ void PX4AutoPilotPlugin::_parametersReadyPreChecks(bool missingParameters)
_incorrectParameterVersion = true;
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.");
}
}
_parametersReady = true;
_missingParameters = missingParameters;

24
src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc

@ -53,9 +53,29 @@ void PX4SimpleFlightModesController::_rcChannelsChanged(int channelCount, int pw @@ -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;

Loading…
Cancel
Save