Fix potential crash when there are errors in a statistics script

This commit is contained in:
Twan van Laarhoven
2020-06-01 14:11:40 +02:00
parent 7952a889c9
commit f9d18ac3c8
3 changed files with 22 additions and 14 deletions
+4 -1
View File
@@ -477,7 +477,7 @@ void StatsPanel::showCategory(const GraphType* prefer_layout) {
// find values for each card
for (size_t i = 0 ; i < set->cards.size() ; ++i) {
Context& ctx = set->getContext(set->cards[i]);
GraphElementP e(new GraphElement(i));
GraphElementP e = make_intrusive<GraphElement>(i);
bool show = true;
FOR_EACH(dim, dims) {
try {
@@ -490,9 +490,12 @@ void StatsPanel::showCategory(const GraphType* prefer_layout) {
}
} catch (ScriptError const& e) {
handle_error(ScriptError(e.what() + _("\n in script for statistics dimension '") + dim->name + _("'")));
show = false;
break;
}
}
if (show) {
assert(e->values.size() == dims.size());
d.elements.push_back(e);
}
}