mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
refs #815 Catch and handle CJsonException when calling convertFromJson.
This commit is contained in:
@@ -1148,16 +1148,25 @@ namespace BlackCore
|
||||
if (!simAircraft.isPartsSynchronized() && !isFull) { return; }
|
||||
|
||||
CAircraftParts parts;
|
||||
if (isFull)
|
||||
try
|
||||
{
|
||||
parts.convertFromJson(jsonObject);
|
||||
if (isFull)
|
||||
{
|
||||
parts.convertFromJson(jsonObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
// incremental update
|
||||
parts = this->remoteAircraftParts(callsign).frontOrDefault();
|
||||
QJsonObject config = applyIncrementalObject(parts.toJson(), jsonObject);
|
||||
parts.convertFromJson(config);
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (const CJsonException &ex)
|
||||
{
|
||||
// incremental update
|
||||
parts = this->remoteAircraftParts(callsign).frontOrDefault();
|
||||
QJsonObject config = applyIncrementalObject(parts.toJson(), jsonObject);
|
||||
parts.convertFromJson(config);
|
||||
CStatusMessage message = ex.toStatusMessage(this, "Invalid parts packet");
|
||||
message.setSeverity(CStatusMessage::SeverityDebug);
|
||||
CLogMessage::preformatted(message);
|
||||
}
|
||||
|
||||
// make sure in any case right time
|
||||
|
||||
@@ -175,7 +175,7 @@ namespace BlackCore
|
||||
CApplicationInfoList CApplication::getRunningApplications()
|
||||
{
|
||||
CApplicationInfoList apps;
|
||||
apps.convertFromJson(CFileUtils::readLockedFileToString(swiftDataRoot() + "apps.json"));
|
||||
apps.convertFromJsonNoThrow(CFileUtils::readLockedFileToString(swiftDataRoot() + "apps.json"), {}, {});
|
||||
apps.removeIf([](const CApplicationInfo &info) { return !info.processInfo().exists(); });
|
||||
return apps;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user