mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:43:23 +00:00
undo: don't add dive to null-trip
In moveDiveToTrip(), the dive was first removed from its old trip and then added to the new trip. This function is also used to remove the dive from its trip (by moving it to the "null-trip" if you whish). Even in that case add_dive_to_trip() was called. The only reason why this didn't crash is that add_dive_to_trip() checks whether old and new trip are the same. This is the case when adding to the "null-trip", since the dive was removed from the trip just before. To cut a long story short, to trust on add_dive_to_trip() not crashing if moving from the null-trip to the null-trip is way to subtly. If we remove a dive from its trip, don't call add_dive_to_trip() in the first place. Reported-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
c6f73ae144
commit
e761d00ddd
1 changed files with 2 additions and 1 deletions
|
@ -271,6 +271,7 @@ static OwningTripPtr moveDiveToTrip(DiveToTrip &diveToTrip)
|
|||
|
||||
// Store old trip and get new trip we should associate this dive with
|
||||
std::swap(trip, diveToTrip.trip);
|
||||
if (trip)
|
||||
add_dive_to_trip(diveToTrip.dive, trip);
|
||||
invalidate_dive_cache(diveToTrip.dive); // Ensure that dive is written in git_save()
|
||||
return res;
|
||||
|
|
Loading…
Add table
Reference in a new issue