diff options
author | jan Iversen <jan@casacondor.com> | 2020-01-30 10:45:55 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-01-30 19:55:47 +0200 |
commit | 9452a78b1d9f69121d81f345a5c3dbf2e100cf74 (patch) | |
tree | 61bcc10e2c37b358b819410a3e4b5eb77b24d8af | |
parent | a65ec772636e17c147c190f84872310d1deea067 (diff) | |
download | subsurface-9452a78b1d9f69121d81f345a5c3dbf2e100cf74.tar.gz |
divesummary: fix potential division by zero
[Dirk Hohndel: extracted from a larger commit from Jan]
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | backend-shared/divesummary.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/backend-shared/divesummary.cpp b/backend-shared/divesummary.cpp index 12d7ff0e2..d9300f429 100644 --- a/backend-shared/divesummary.cpp +++ b/backend-shared/divesummary.cpp @@ -175,9 +175,14 @@ void diveSummary::buildStringList(int inx) unitText = (qPrefUnits::volume() == units::LITER) ? " l/min" : " cuft/min"; diveSummaryText[18+inx] = volumeString(sacMin[inx]) + unitText; diveSummaryText[20+inx] = volumeString(sacMax[inx]) + unitText; + // finally the weighted average - long avgSac = totalSacVolume[inx] / totalSACTime[inx]; - diveSummaryText[22+inx] = volumeString(avgSac) + unitText; + if (totalSACTime[inx]) { + long avgSac = totalSacVolume[inx] / totalSACTime[inx]; + diveSummaryText[22+inx] = volumeString(avgSac) + unitText; + } else { + diveSummaryText[22+inx] = QObject::tr("no dives"); + } // Diveplan(s) diveSummaryText[24+inx] = QStringLiteral("%1").arg(diveplans[inx]); |