Merge pull request #2997 from OpenSpace/issue/2976

Fix for crash when reading meta of corrupt config file
This commit is contained in:
Gene Payne
2024-01-16 14:48:13 -07:00
committed by GitHub
2 changed files with 11 additions and 4 deletions

View File

@@ -588,10 +588,17 @@ bool handleConfigurationFile(QComboBox& box, const std::filesystem::directory_en
// Add tooltip
if (isJson) {
sgct::config::Meta meta = sgct::readMeta(p.path().string(), true);
if (!meta.description.empty()) {
std::string tooltipDescription;
try {
sgct::config::Meta meta = sgct::readMeta(p.path().string());
tooltipDescription = meta.description;
}
catch (const sgct::Error&) {
tooltipDescription = "(no description available)";
}
if (!tooltipDescription.empty()) {
QString toolTip = QString::fromStdString(
fmt::format("<p>{}</p>", meta.description)
fmt::format("<p>{}</p>", tooltipDescription)
);
box.setItemData(box.count() - 1, toolTip, Qt::ToolTipRole);
}