From 0618aa737fde54e634d16273ec0246ced9c454aa Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 8 Nov 2018 17:13:17 +0100 Subject: Core: unify insert_trip() and insert_trip_dont_merge() There were two versions of the insert_trip() function: one would merge trips if a trip with the same date already existed, the other wouldn't. The latter was introduced with the dive-list undo work. The problem is that the "date" of a trip (i.e. the first dive) seems ill-defined as this is a volatile value. Moreover in the context of making dive-import undoable this is a very dangerous notion, as the caller needs control over when the dives are added to a trip. Therefore, unify these two functions and never merge trips. The decision on merging dives now has to made by the caller. This will be implemented in a future commit. Signed-off-by: Berthold Stoeger --- desktop-widgets/command_divelist.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/command_divelist.cpp b/desktop-widgets/command_divelist.cpp index e129fefdd..9f4ea8cd2 100644 --- a/desktop-widgets/command_divelist.cpp +++ b/desktop-widgets/command_divelist.cpp @@ -82,7 +82,7 @@ DiveToAdd DiveListBase::removeDive(struct dive *d) dive *DiveListBase::addDive(DiveToAdd &d) { if (d.tripToAdd) - insert_trip_dont_merge(d.tripToAdd.release()); // Return ownership to backend + insert_trip(d.tripToAdd.release()); // Return ownership to backend if (d.trip) add_dive_to_trip(d.dive.get(), d.trip); dive *res = d.dive.release(); // Give up ownership of dive @@ -259,7 +259,7 @@ static void moveDivesBetweenTrips(DivesToTrip &dives) for (OwningTripPtr &trip: dives.tripsToAdd) { dive_trip *t = trip.release(); // Give up ownership createdTrips.push_back(t); - insert_trip_dont_merge(t); // Return ownership to backend + insert_trip(t); // Return ownership to backend } dives.tripsToAdd.clear(); -- cgit v1.2.3-70-g09d2