aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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));