aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-02 21:53:17 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-03 13:41:15 -0800
commit76d94eda235fe0883d88982ad55cef0c0cf9014b (patch)
tree1ed3a6e0aa1fca560f845cb56a79ca302db2337c
parent402e7eaf97916fe61b283dd4eb7be6672f37144b (diff)
downloadsubsurface-76d94eda235fe0883d88982ad55cef0c0cf9014b.tar.gz
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>
-rw-r--r--stats/legend.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/stats/legend.cpp b/stats/legend.cpp
index 7418df9df..927e972c8 100644
--- a/stats/legend.cpp
+++ b/stats/legend.cpp
@@ -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));