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>
This commit is contained in:
Berthold Stoeger 2019-06-23 21:36:54 +02:00 committed by Dirk Hohndel
parent d60ec98e8e
commit 019eeec93d

View file

@ -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