fix: Skip invalid EngineList JSON entries

The ACCONFIG might contain other entries which
are not numeric (like "HasEngines" sent from xPilot)
This commit is contained in:
Lars Toenning
2026-08-14 19:16:39 +02:00
parent c130cc63ea
commit 6cd1273b5b

View File

@@ -108,10 +108,16 @@ namespace swift::misc::aviation
this->clear();
for (const auto &e : json.keys())
{
CAircraftEngine engine;
const int number = e.toInt();
bool ok{false};
const int number = e.toInt(&ok);
if (!ok || number <= 0)
{
// skip invalid JSON entries
return;
}
CJsonScope scope(e);
Q_UNUSED(scope);
CAircraftEngine engine;
engine.convertFromJson(json.value(e).toObject());
engine.setNumber(number);
push_back(engine);