Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix case-sensitive flight mode comparisons #12191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AutoPilotPlugins/APM/APMSubMotorComponentController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void APMSubMotorComponentController::handleNewMessages(int uasid, int componenti
Q_UNUSED(uasid);
Q_UNUSED(componentid);
Q_UNUSED(severity);
if (_vehicle->flightMode() == "Motor Detection"
if (QString::compare(_vehicle->flightMode(), "Motor Detection", Qt::CaseInsensitive) == 0
&& (text.toLower().contains("thruster") || text.toLower().contains("motor"))) {
_motorDetectionMessages += text + QStringLiteral("\n");
emit motorDetectionMessagesChanged();
Expand Down
2 changes: 1 addition & 1 deletion src/FirmwarePlugin/APM/APMFirmwarePlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ const QVariantList& APMFirmwarePlugin::toolIndicators(const Vehicle* vehicle)

bool APMFirmwarePlugin::isGuidedMode(const Vehicle* vehicle) const
{
return vehicle->flightMode() == "Guided";
return QString::compare(vehicle->flightMode(), "Guided", Qt::CaseInsensitive) == 0;
}

void APMFirmwarePlugin::_soloVideoHandshake(void)
Expand Down
4 changes: 2 additions & 2 deletions src/FirmwarePlugin/FirmwarePlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ bool FirmwarePlugin::_armVehicleAndValidate(Vehicle* vehicle)

bool FirmwarePlugin::_setFlightModeAndValidate(Vehicle* vehicle, const QString& flightMode)
{
if (vehicle->flightMode() == flightMode) {
if (QString::compare(vehicle->flightMode(), flightMode, Qt::CaseInsensitive) == 0) {
return true;
}

Expand All @@ -377,7 +377,7 @@ bool FirmwarePlugin::_setFlightModeAndValidate(Vehicle* vehicle, const QString&

// Wait for vehicle to return flight mode
for (int i=0; i<13; i++) {
if (vehicle->flightMode() == flightMode) {
if (QString::compare(vehicle->flightMode(), flightMode, Qt::CaseInsensitive) == 0) {
flightModeChanged = true;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Vehicle/StandardModes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ QString StandardModes::flightMode(uint32_t custom_mode) const
bool StandardModes::setFlightMode(const QString &flightMode, uint32_t *custom_mode)
{
for (auto iter = _modes.constBegin(); iter != _modes.constEnd(); ++iter) {
if (iter->name == flightMode) {
if (QString::compare(iter->name, flightMode, Qt::CaseInsensitive) == 0) {
*custom_mode = iter.key();
return true;
}
Expand Down
Loading