From a791bf2e8ec798cb29d5c20bf0617327cb017269 Mon Sep 17 00:00:00 2001 From: Neil Horne Date: Sun, 24 Mar 2024 14:33:58 +1100 Subject: [PATCH] fix(cpn): model semver check inc model name in warning msg (#4794) --- .../src/firmwares/edgetx/yaml_modeldata.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_modeldata.cpp b/companion/src/firmwares/edgetx/yaml_modeldata.cpp index 9514e1442..4987d126d 100644 --- a/companion/src/firmwares/edgetx/yaml_modeldata.cpp +++ b/companion/src/firmwares/edgetx/yaml_modeldata.cpp @@ -1162,14 +1162,6 @@ bool convert::decode(const Node& node, ModelData& rhs) qDebug() << "Settings version:" << modelSettingsVersion.toString(); - 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"]; if (header.IsMap()) { @@ -1180,6 +1172,15 @@ bool convert::decode(const Node& node, ModelData& rhs) } } + // TODO display model filename in preference to model name as easier for user + if (modelSettingsVersion > SemanticVersion(VERSION)) { + QString prmpt = QCoreApplication::translate("YamlModelSettings", "Warning: Model '%1' has settings version %2 that 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(rhs.name).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["timers"]) { const auto& timers = node["timers"]; if (!timers.IsMap()) return false;