diff --git a/commands/command_divelist.cpp b/commands/command_divelist.cpp index 8d16e0672..3da905120 100644 --- a/commands/command_divelist.cpp +++ b/commands/command_divelist.cpp @@ -922,7 +922,7 @@ MergeDives::MergeDives(const QVector &dives) return; } - auto [d, trip, site] = divelog.dives.merge_dives(*dives[0], *dives[1], dives[1]->when - dives[0]->when, false); + auto [d, trip] = divelog.dives.merge_dives(*dives[0], *dives[1], dives[1]->when - dives[0]->when, false); // Currently, the core code selects the dive -> this is not what we want, as // we manually manage the selection post-command. @@ -932,11 +932,10 @@ MergeDives::MergeDives(const QVector &dives) // Set the preferred dive trip, so that for subsequent merges the better trip can be selected d->divetrip = trip; for (int i = 2; i < dives.count(); ++i) { - auto [d2, trip, site] = divelog.dives.merge_dives(*d, *dives[i], dives[i]->when - d->when, false); + auto [d2, trip] = divelog.dives.merge_dives(*d, *dives[i], dives[i]->when - d->when, false); d = std::move(d2); // Set the preferred dive trip and site, so that for subsequent merges the better trip and site can be selected d->divetrip = trip; - d->dive_site = site; } // The merged dive gets the number of the first dive with a non-zero number diff --git a/core/divelist.cpp b/core/divelist.cpp index d9a08fff4..425d4e94c 100644 --- a/core/divelist.cpp +++ b/core/divelist.cpp @@ -1175,14 +1175,13 @@ merge_result dive_table::merge_dives(const struct dive &a_in, const struct dive res.trip = get_preferred_trip(a, b); /* we take the first dive site, unless it's empty */ - res.site = a->dive_site && !a->dive_site->is_empty() ? a->dive_site : b->dive_site; - if (res.site && !res.site->has_gps_location() && b->dive_site && b->dive_site->has_gps_location()) { + res.dive->dive_site = a->dive_site && !a->dive_site->is_empty() ? a->dive_site : b->dive_site; + if (res.dive->dive_site && !res.dive->dive_site->has_gps_location() && b->dive_site && b->dive_site->has_gps_location()) { /* we picked the first dive site and that didn't have GPS data, but the new dive has * GPS data (that could be a download from a GPS enabled dive computer). * Keep the dive site, but add the GPS data */ - res.site->location = b->dive_site->location; + res.dive->dive_site->location = b->dive_site->location; } - res.dive->dive_site = res.site; fixup_dive(*res.dive); return res; @@ -1206,8 +1205,7 @@ struct std::unique_ptr dive_table::try_to_merge(const struct dive &a, cons if (!a.likely_same(b)) return {}; - auto [res, trip, site] = merge_dives(a, b, 0, prefer_downloaded); - res->dive_site = site; /* Caller has to call site->add_dive()! */ + auto [res, trip] = merge_dives(a, b, 0, prefer_downloaded); return std::move(res); } diff --git a/core/divelist.h b/core/divelist.h index a41e44e51..e93683434 100644 --- a/core/divelist.h +++ b/core/divelist.h @@ -18,7 +18,6 @@ int comp_dives_ptr(const struct dive *a, const struct dive *b); struct merge_result { std::unique_ptr dive; dive_trip *trip; - dive_site *site; }; struct dive_table : public sorted_owning_table {