fixcpn): use model semver over radio semver for decoding model sources and switches (#4768)

This commit is contained in:
Neil Horne
2024-03-24 11:39:24 +10:00
committed by GitHub
parent ac8705f13b
commit 1b73d7530d
3 changed files with 13 additions and 9 deletions
@@ -38,8 +38,7 @@
#include "helpers.h"
#include <string>
SemanticVersion version; // used for data conversions
#include <QMessageBox>
void YamlValidateLabelsNames(ModelData& model, Board::Type board)
{
@@ -867,7 +866,7 @@ struct convert<FrSkyScreenData> {
Node convert<ModelData>::encode(const ModelData& rhs)
{
version = SemanticVersion(VERSION);
modelSettingsVersion = SemanticVersion(VERSION);
Node node;
auto board = getCurrentBoard();
@@ -1163,8 +1162,13 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
qDebug() << "Settings version:" << modelSettingsVersion.toString();
if (modelSettingsVersion > SemanticVersion(VERSION))
qDebug() << "Warning: version not supported by Companion!";
if (modelSettingsVersion > SemanticVersion(VERSION)) {
QString prmpt = QCoreApplication::translate("YamlModelSettings", "Warning: Model settings file version %1 is not supported by this version of Companion!\n\nModel and radio settings may be corrupted if you continue.\n\nI acknowledge and accept the consequences.");
if (QMessageBox::warning(NULL, CPN_STR_APP_NAME, prmpt.arg(modelSettingsVersion.toString()), (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) != QMessageBox::Yes) {
// TODO: this triggers an error in the calling code so we need a graceful way to handle
return false;
}
}
if (node["header"]) {
const auto& header = node["header"];