Skip to content

Commit ec2135b

Browse files
committed
fix(cpn): 2.12 workaround suppress warnings reading 3.0 yaml
1 parent d51c2e7 commit ec2135b

File tree

2 files changed

+44
-28
lines changed

2 files changed

+44
-28
lines changed

companion/src/firmwares/edgetx/yaml_generalsettings.cpp

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -422,20 +422,28 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
422422
qDebug() << "Settings version:" << radioSettingsVersion.toString();
423423

424424
if (radioSettingsVersion > SemanticVersion(VERSION)) {
425-
QString prmpt = QCoreApplication::translate("YamlGeneralSettings", "Warning: File version %1 is not supported by this version of Companion!\n\nModel and radio settings may be corrupted if you continue.");
426-
prmpt = prmpt.arg(radioSettingsVersion.toString());
427-
QMessageBox msgBox;
428-
msgBox.setWindowTitle(QCoreApplication::translate("YamlGeneralSettings", "Read Radio Settings"));
429-
msgBox.setText(prmpt);
430-
msgBox.setIcon(QMessageBox::Warning);
431-
QPushButton *pbAccept = new QPushButton(CPN_STR_TTL_ACCEPT);
432-
QPushButton *pbDecline = new QPushButton(CPN_STR_TTL_DECLINE);
433-
msgBox.addButton(pbAccept, QMessageBox::AcceptRole);
434-
msgBox.addButton(pbDecline, QMessageBox::RejectRole);
435-
msgBox.setDefaultButton(pbDecline);
436-
msgBox.exec();
437-
if (msgBox.clickedButton() == pbDecline)
438-
return false;
425+
// TODO remove this temporary 2.12 fix check for 3.0 release
426+
if (radioSettingsVersion == SemanticVersion("3.0.0") &&
427+
SemanticVersion(VERSION) >= SemanticVersion("2.12.0") &&
428+
SemanticVersion(VERSION) < SemanticVersion("3.0.0")) {
429+
qDebug() << "Version exception override: radio settings" << radioSettingsVersion.toString()
430+
<< "Companion" << SemanticVersion(VERSION).toString();
431+
} else {
432+
QString prmpt = QCoreApplication::translate("YamlGeneralSettings", "Warning: File version %1 is not supported by Companion %2!\n\nModel and radio settings may be corrupted if you continue.");
433+
prmpt = prmpt.arg(radioSettingsVersion.toString()).arg(SemanticVersion(VERSION).toString());
434+
QMessageBox msgBox;
435+
msgBox.setWindowTitle(QCoreApplication::translate("YamlGeneralSettings", "Read Radio Settings"));
436+
msgBox.setText(prmpt);
437+
msgBox.setIcon(QMessageBox::Warning);
438+
QPushButton *pbAccept = new QPushButton(CPN_STR_TTL_ACCEPT);
439+
QPushButton *pbDecline = new QPushButton(CPN_STR_TTL_DECLINE);
440+
msgBox.addButton(pbAccept, QMessageBox::AcceptRole);
441+
msgBox.addButton(pbDecline, QMessageBox::RejectRole);
442+
msgBox.setDefaultButton(pbDecline);
443+
msgBox.exec();
444+
if (msgBox.clickedButton() == pbDecline)
445+
return false;
446+
}
439447
}
440448

441449
rhs.version = CPN_CURRENT_SETTINGS_VERSION; // depreciated in EdgeTX however data conversions use

companion/src/firmwares/edgetx/yaml_modeldata.cpp

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,20 +1340,28 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
13401340

13411341
// TODO display model filename in preference to model name as easier for user
13421342
if (modelSettingsVersion > SemanticVersion(VERSION)) {
1343-
QString prmpt = QCoreApplication::translate("YamlModelSettings", "Warning: '%1' has settings version %2 that is not supported by this version of Companion!\n\nModel settings may be corrupted if you continue.");
1344-
prmpt = prmpt.arg(rhs.name).arg(modelSettingsVersion.toString());
1345-
QMessageBox msgBox;
1346-
msgBox.setWindowTitle(QCoreApplication::translate("YamlModelSettings", "Read Model Settings"));
1347-
msgBox.setText(prmpt);
1348-
msgBox.setIcon(QMessageBox::Warning);
1349-
QPushButton *pbAccept = new QPushButton(CPN_STR_TTL_ACCEPT);
1350-
QPushButton *pbDecline = new QPushButton(CPN_STR_TTL_DECLINE);
1351-
msgBox.addButton(pbAccept, QMessageBox::AcceptRole);
1352-
msgBox.addButton(pbDecline, QMessageBox::RejectRole);
1353-
msgBox.setDefaultButton(pbDecline);
1354-
msgBox.exec();
1355-
if (msgBox.clickedButton() == pbDecline)
1356-
return false;
1343+
// TODO remove this check as part of 3.0 release
1344+
if (modelSettingsVersion == SemanticVersion("3.0.0") &&
1345+
SemanticVersion(VERSION) >= SemanticVersion("2.12.0") &&
1346+
SemanticVersion(VERSION) < SemanticVersion("3.0.0")) {
1347+
qDebug() << "Version exception override: radio settings" << modelSettingsVersion.toString()
1348+
<< "Companion" << SemanticVersion(VERSION).toString();
1349+
} else {
1350+
QString prmpt = QCoreApplication::translate("YamlModelSettings", "Warning: '%1' has settings version %2 that is not supported by Companion %3!\n\nModel settings may be corrupted if you continue.");
1351+
prmpt = prmpt.arg(rhs.name).arg(modelSettingsVersion.toString()).arg(SemanticVersion(VERSION).toString());
1352+
QMessageBox msgBox;
1353+
msgBox.setWindowTitle(QCoreApplication::translate("YamlModelSettings", "Read Model Settings"));
1354+
msgBox.setText(prmpt);
1355+
msgBox.setIcon(QMessageBox::Warning);
1356+
QPushButton *pbAccept = new QPushButton(CPN_STR_TTL_ACCEPT);
1357+
QPushButton *pbDecline = new QPushButton(CPN_STR_TTL_DECLINE);
1358+
msgBox.addButton(pbAccept, QMessageBox::AcceptRole);
1359+
msgBox.addButton(pbDecline, QMessageBox::RejectRole);
1360+
msgBox.setDefaultButton(pbDecline);
1361+
msgBox.exec();
1362+
if (msgBox.clickedButton() == pbDecline)
1363+
return false;
1364+
}
13571365
}
13581366

13591367
if (node["timers"]) {

0 commit comments

Comments
 (0)