aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-06-23 21:36:54 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-06-28 20:23:01 +0900
commit019eeec93d3399a2e277ff9399320764043e38c1 (patch)
tree74c87f58b7a304e84ed4e9717339bc81692ceb8d
parentd60ec98e8e03076563623c550e81d22571d91e15 (diff)
downloadsubsurface-019eeec93d3399a2e277ff9399320764043e38c1.tar.gz
Dive merge: don't use unset dive numbers
On merging, don't use the number of the first dive if it is 0. Use the first non-zero number. Fixes #2126 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--desktop-widgets/command_divelist.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/desktop-widgets/command_divelist.cpp b/desktop-widgets/command_divelist.cpp
index 5a318e8a3..0796c6f5f 100644
--- a/desktop-widgets/command_divelist.cpp
+++ b/desktop-widgets/command_divelist.cpp
@@ -918,8 +918,13 @@ MergeDives::MergeDives(const QVector <dive *> &dives)
d->divetrip = nullptr;
d->dive_site = nullptr;
- // The merged dive gets the number of the first dive
- d->number = dives[0]->number;
+ // The merged dive gets the number of the first dive with a non-zero number
+ for (const dive *dive: dives) {
+ if (dive->number) {
+ d->number = dive->number;
+ break;
+ }
+ }
// We will only renumber the remaining dives if the joined dives are consecutive.
// Otherwise all bets are off concerning what the user wanted and doing nothing seems