diff --git a/companion/src/firmwares/edgetx/edgetxinterface.cpp b/companion/src/firmwares/edgetx/edgetxinterface.cpp index 49e205107..709c06c6e 100644 --- a/companion/src/firmwares/edgetx/edgetxinterface.cpp +++ b/companion/src/firmwares/edgetx/edgetxinterface.cpp @@ -83,20 +83,14 @@ bool loadModelsListFromYaml(std::vector& categories, bool loadModelFromYaml(ModelData& model, const QByteArray& data) { - try { YAML::Node node = loadYamlFromByteArray(data); node >> model; - } catch (const std::runtime_error& e) { - qDebug() << "YAML::ParserException: " << e.what(); - return false; - } return true; } bool loadRadioSettingsFromYaml(GeneralSettings& settings, const QByteArray& data) { - try { YAML::Node node = loadYamlFromByteArray(data); node >> settings; if (settings.version < CPN_CURRENT_SETTINGS_VERSION) { @@ -107,10 +101,6 @@ bool loadRadioSettingsFromYaml(GeneralSettings& settings, const QByteArray& data QMessageBox::critical(NULL, CPN_STR_APP_NAME, QCoreApplication::translate("EdgeTXInterface", "Companion does not support settings version %1!").arg(settings.version)); return false; } - } catch (const std::runtime_error& e) { - qDebug() << "YAML::ParserException: " << e.what(); - return false; - } return true; } diff --git a/companion/src/firmwares/edgetx/yaml_ops.h b/companion/src/firmwares/edgetx/yaml_ops.h index 52a40ab65..539db8b96 100644 --- a/companion/src/firmwares/edgetx/yaml_ops.h +++ b/companion/src/firmwares/edgetx/yaml_ops.h @@ -98,18 +98,18 @@ void operator>>(const YAML::Node& node, T (&value)[N]) if (!node) return; if (node.IsMap()) { for (const auto& elmt : node) { + int idx = -1; try { - int idx = std::stoi(elmt.first.Scalar()); - if (idx < 0 || idx >= (int)N) return; - - if (elmt.second.IsMap() && (elmt.second.size() == 1) && - elmt.second["val"]) { - elmt.second["val"] >> value[idx]; - } else { - elmt.second >> value[idx]; - } + idx = std::stoi(elmt.first.Scalar()); } catch (...) { - return; + } + if (idx < 0 || idx >= (int)N) continue; + + if (elmt.second.IsMap() && (elmt.second.size() == 1) && + elmt.second["val"]) { + elmt.second["val"] >> value[idx]; + } else { + elmt.second >> value[idx]; } } } else if (node.IsSequence()) { diff --git a/companion/src/storage/categorized.cpp b/companion/src/storage/categorized.cpp index 7eb8af901..4c3caf7c2 100644 --- a/companion/src/storage/categorized.cpp +++ b/companion/src/storage/categorized.cpp @@ -237,8 +237,13 @@ bool CategorizedStorageFormat::loadYaml(RadioData & radioData) return false; } - if (!loadRadioSettingsFromYaml(radioData.generalSettings, radioSettingsBuffer)) { - setError(tr("Can't load RADIO/radio.yml")); + try { + if (!loadRadioSettingsFromYaml(radioData.generalSettings, radioSettingsBuffer)) { + setError(tr("Can't load RADIO/radio.yml")); + return false; + } + } catch(const std::runtime_error& e) { + setError(tr("Can't load RADIO/radio.yml") + ":\n" + QString(e.what())); return false; } @@ -249,8 +254,6 @@ bool CategorizedStorageFormat::loadYaml(RadioData & radioData) QByteArray modelslistBuffer; if (loadFile(modelslistBuffer, "MODELS/models.yml")) { - - if (!loadModelsListFromYaml(radioData.categories, modelFiles, modelslistBuffer)) { setError(tr("Can't load MODELS/models.yml")); return false; @@ -292,8 +295,13 @@ bool CategorizedStorageFormat::loadYaml(RadioData & radioData) // auto& model = radioData.models[mc.modelIdx]; - if (!loadModelFromYaml(model,modelBuffer)) { - setError(tr("Can't load ") + filename); + try { + if (!loadModelFromYaml(model,modelBuffer)) { + setError(tr("Can't load ") + filename); + return false; + } + } catch(const std::runtime_error& e) { + setError(tr("Can't load ") + filename + ":\n" + QString(e.what())); return false; }