mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-15 10:02:52 +08:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user