mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
statistics: don't divide by totalCount = 0 in pie charts
This silences a Coverity warning. In principle, this should never happen, since there are no slices if totalCount is 0. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
3fcac9022c
commit
7446e8cddd
1 changed files with 5 additions and 0 deletions
|
@ -27,6 +27,11 @@ PieSeries::Item::Item(StatsView &view, const QString &name, int from, std::vecto
|
|||
QLocale loc;
|
||||
|
||||
int count = (int)dives.size();
|
||||
|
||||
// totalCount = 0 shouldn't happen, but for robustness' sake, let's not divide by zero.
|
||||
if (totalCount <= 0)
|
||||
totalCount = count = 1;
|
||||
|
||||
angleFrom = static_cast<double>(from) / totalCount;
|
||||
angleTo = static_cast<double>(from + count) / totalCount;
|
||||
double meanAngle = M_PI / 2.0 - (from + count / 2.0) / totalCount * M_PI * 2.0; // Note: "-" because we go CW.
|
||||
|
|
Loading…
Reference in a new issue