From 6ac4ddbeeda5286faacac9633b622dcf298eea7b Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 28 Jul 2018 21:26:59 +0200 Subject: Core: introduce insert_trip_dont_merge() function insert_trip() adds a trip to the backend, but merges trips if there exists a trip with the same date. This is a disaster for the MergeTrips command, because this command adds a new trip and removes the previous two. Of course if the added trip is merged, this cannot work. Therefore, add an insert_trip_dont_merge() function, which adds the trip, but doesn't merge. Signed-off-by: Berthold Stoeger --- desktop-widgets/command_divelist.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/command_divelist.cpp b/desktop-widgets/command_divelist.cpp index d12aebfc2..f0c0a82e2 100644 --- a/desktop-widgets/command_divelist.cpp +++ b/desktop-widgets/command_divelist.cpp @@ -34,10 +34,8 @@ static DiveToAdd removeDive(struct dive *d) // Returns pointer to added dive (which is owned by the backend!) static dive *addDive(DiveToAdd &d) { - if (d.tripToAdd) { - dive_trip *t = d.tripToAdd.release(); // Give up ownership of trip - insert_trip(&t); // Return ownership to backend - } + if (d.tripToAdd) + insert_trip_dont_merge(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 @@ -124,10 +122,8 @@ static OwningTripPtr moveDiveToTrip(DiveToTrip &diveToTrip) static void moveDivesBetweenTrips(DivesToTrip &dives) { // first bring back the trip(s) - for (OwningTripPtr &trip: dives.tripsToAdd) { - dive_trip *t = trip.release(); // Give up ownership - insert_trip(&t); // Return ownership to backend - } + for (OwningTripPtr &trip: dives.tripsToAdd) + insert_trip_dont_merge(trip.release()); // Return ownership to backend dives.tripsToAdd.clear(); for (DiveToTrip &dive: dives.divesToMove) { -- cgit v1.2.3-70-g09d2