statistics: silence two Coverity warnings

Two warnings concerning division by zero and non-initialization
of a member variable, respectively.

Both are false positives. However, Coverity is excused because
it probably doesn't understand std::vector<> and also can't
know whether the object in question is generated in a different
source file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-01-02 21:53:17 +01:00 committed by Dirk Hohndel
parent 402e7eaf97
commit 76d94eda23

View file

@ -32,7 +32,9 @@ Legend::Legend(QGraphicsWidget *chart, const std::vector<QString> &names) :
e.width = fontHeight + 2.0 * legendBoxBorderSize +
fm.size(Qt::TextSingleLine, e.text->text()).width();
} else {
fontHeight = 0.0;
// Set to an arbitrary non-zero value, because Coverity doesn't understand
// that we don't use the value as divisor below if entries is empty.
fontHeight = 10.0;
}
setPen(QPen(legendBorderColor, legendBorderSize));
setBrush(QBrush(legendColor));
@ -42,7 +44,8 @@ Legend::Legend(QGraphicsWidget *chart, const std::vector<QString> &names) :
Legend::Entry::Entry(const QString &name, int idx, int numBins, QGraphicsItem *parent) :
rect(new QGraphicsRectItem(parent)),
text(new QGraphicsSimpleTextItem(name, parent))
text(new QGraphicsSimpleTextItem(name, parent)),
width(0)
{
rect->setZValue(ZValues::legend);
rect->setPen(QPen(legendBorderColor, legendBoxBorderSize));