fixcpn): use model semver over radio semver for decoding model sources and switches (#4768)
This commit is contained in:
@@ -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"];
|
||||
|
||||
@@ -263,7 +263,7 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
|
||||
std::string ana_str;
|
||||
node >> ana_str;
|
||||
|
||||
if (radioSettingsVersion < SemanticVersion(QString(CPN_ADC_REFACTOR_VERSION))) {
|
||||
if (modelSettingsVersion < SemanticVersion(QString(CPN_ADC_REFACTOR_VERSION))) {
|
||||
ana_str = Boards::getLegacyAnalogMappedInputTag(ana_str.c_str());
|
||||
int idx = Boards::getInputIndex(ana_str.c_str(), Board::LVT_TAG);
|
||||
if (idx >= 0 && Boards::isInputStick(idx))
|
||||
@@ -280,7 +280,7 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
|
||||
std::string trim_str;
|
||||
node >> trim_str;
|
||||
|
||||
if (radioSettingsVersion < SemanticVersion(QString(CPN_ADC_REFACTOR_VERSION))) {
|
||||
if (modelSettingsVersion < SemanticVersion(QString(CPN_ADC_REFACTOR_VERSION))) {
|
||||
int idx = b.getLegacyTrimSourceIndex(src_str.c_str());
|
||||
if (idx >= 0)
|
||||
trim_str = Boards::getTrimYamlName(idx, BoardJson::YLT_REF).toStdString();
|
||||
@@ -296,7 +296,7 @@ RawSource YamlRawSourceDecode(const std::string& src_str)
|
||||
std::string special_str;
|
||||
node >> special_str;
|
||||
|
||||
if (radioSettingsVersion < SemanticVersion(QString(CPN_ADC_REFACTOR_VERSION))) {
|
||||
if (modelSettingsVersion < SemanticVersion(QString(CPN_ADC_REFACTOR_VERSION))) {
|
||||
if (special_str.size() == 6 && special_str.substr(0, 5) == "TIMER") {
|
||||
special_str = "Tmr" + special_str.substr(5, 1);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ RawSwitch YamlRawSwitchDecode(const std::string& sw_str)
|
||||
try {
|
||||
mp_input_index = std::stoi(sw_str_tmp.substr(2, val_len - 3));
|
||||
|
||||
if (radioSettingsVersion < SemanticVersion(QString(CPN_ADC_REFACTOR_VERSION))) {
|
||||
if (modelSettingsVersion < SemanticVersion(QString(CPN_ADC_REFACTOR_VERSION))) {
|
||||
if (IS_HORUS_X10(board) || IS_FAMILY_T16(board)) {
|
||||
if (mp_input_index > 2)
|
||||
mp_input_index += 2;
|
||||
|
||||
Reference in New Issue
Block a user