Skip to content

Commit f920e83

Browse files
committed
LP-558 accept case insensitive uav enum values
this is needed because TRUE/FALSE enum has been changed to True/False but old TRUE/FALSE is used by templates LP templates can be fixed but users' templates can't logic is now to try case sensitive, if that fails try case insensitive if case insensitive works, a warning is logged a new warning is also logged if the enum can't be found at all
1 parent 2f1e7cd commit f920e83

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

ground/gcs/src/plugins/uavobjects/uavobjectfield.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,9 +1152,18 @@ void UAVObjectField::setValue(const QVariant & value, quint32 index)
11521152
case ENUM:
11531153
{
11541154
qint8 tmpenum = options.indexOf(value.toString());
1155+
// try case insensitive
1156+
if (tmpenum < 0) {
1157+
QRegExp regexp(value.toString(), Qt::CaseInsensitive);
1158+
tmpenum = options.indexOf(regexp);
1159+
if (tmpenum >= 0) {
1160+
qWarning() << "Enum value" << value.toString() << "should be" << options.at(tmpenum);
1161+
}
1162+
}
11551163
// Default to 0 on invalid values.
11561164
if (tmpenum < 0) {
11571165
tmpenum = 0;
1166+
qWarning() << "Enum value" << value.toString() << "not found";
11581167
}
11591168
memcpy(&data[offset + numBytesPerElement * index], &tmpenum, numBytesPerElement);
11601169
break;

0 commit comments

Comments
 (0)