From ba93abc30c9b23be400d8f3babd25712f6405ef6 Mon Sep 17 00:00:00 2001 From: Neil Horne Date: Tue, 8 Feb 2022 12:17:32 +1100 Subject: [PATCH] fix: Companion no longer implies will convert if profile mismatch on read + add board parameter if missing (#1572) --- .../firmwares/edgetx/yaml_generalsettings.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp index 6464cece5..e3a258d7d 100644 --- a/companion/src/firmwares/edgetx/yaml_generalsettings.cpp +++ b/companion/src/firmwares/edgetx/yaml_generalsettings.cpp @@ -241,17 +241,21 @@ bool convert::decode(const Node& node, GeneralSettings& rhs) node["board"] >> flavour; auto fw = getCurrentFirmware(); - auto msfw = Firmware::getFirmwareForFlavour(QString(flavour.c_str())); - - if (flavour.empty()) { - qDebug() << "Warning: Settings file does not contain board flavour! Default firmware board will be used"; - flavour = msfw->getFlavour().toStdString(); - } qDebug() << "Settings version:" << rhs.version << "File flavour:" << flavour.c_str() << "Firmware flavour:" << fw->getFlavour(); - if (fw->getFlavour().toStdString() != flavour) { - QString prmpt = QCoreApplication::translate("YamlGeneralSettings", "File board (%1) does not match current profile board (%2), models and settings will be converted where possible.\n\nDo you wish to continue?").arg(Boards::getBoardName(msfw->getBoard())).arg(Boards::getBoardName(fw->getBoard())); + if (flavour.empty()) { + QString prmpt = QCoreApplication::translate("YamlGeneralSettings", "Warning: Radio settings file is missing the board entry!\n\nCurrent firmware profile board will be used.\n\nDo you wish to continue?"); + if (QMessageBox::question(NULL, CPN_STR_APP_NAME, prmpt, (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; + } + flavour = fw->getFlavour().toStdString(); + } + else if (fw->getFlavour().toStdString() != flavour) { + auto msfw = Firmware::getFirmwareForFlavour(QString(flavour.c_str())); + + QString prmpt = QCoreApplication::translate("YamlGeneralSettings", "Settings file board (%1) does not match current profile board (%2).\n\nDo you wish to continue?").arg(Boards::getBoardName(msfw->getBoard())).arg(Boards::getBoardName(fw->getBoard())); if (QMessageBox::question(NULL, CPN_STR_APP_NAME, prmpt, (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