fix(cpn): Prevent crashing due to malformed theme.yml files (#1970)
Malformed yaml theme files would cause Companion to crash without indication of fault.
This commit is contained in:
@@ -81,7 +81,9 @@ UserInterfacePanel::UserInterfacePanel(QWidget * parent, ModelData & model, Gene
|
|||||||
|
|
||||||
if (QFile(selThemeDetails).exists()) {
|
if (QFile(selThemeDetails).exists()) {
|
||||||
|
|
||||||
|
try {
|
||||||
YAML::Node node = YAML::LoadFile(selThemeDetails.toStdString());
|
YAML::Node node = YAML::LoadFile(selThemeDetails.toStdString());
|
||||||
|
|
||||||
if (node["summary"]) {
|
if (node["summary"]) {
|
||||||
const auto &summary = node["summary"];
|
const auto &summary = node["summary"];
|
||||||
if (summary.IsMap()) {
|
if (summary.IsMap()) {
|
||||||
@@ -93,6 +95,10 @@ UserInterfacePanel::UserInterfacePanel(QWidget * parent, ModelData & model, Gene
|
|||||||
themeInfo = summary["info"].as<std::string>();
|
themeInfo = summary["info"].as<std::string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch(const std::runtime_error& e) {
|
||||||
|
QMessageBox::warning(this, CPN_STR_APP_NAME, tr("Cannot load %1").arg(selThemeDetails) + ":\n" + QString(e.what()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user