mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Dive list: remove trip from model only once
In moveDivesBetweenTrips() a the model is informed of dives that are moved between trips. A flag tells the model to delete empty trips. If dives were removed in batches [use case: split a big trip into multiple smaller trips] the flag would be sent for every batch. This was handled gracefully by the model code, but it gave a warning message. Set the flag only for the last batch, when the trip is *really* empty. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
3cdc2661d2
commit
2706fa7b8e
1 changed files with 5 additions and 2 deletions
|
@ -305,9 +305,12 @@ static void moveDivesBetweenTrips(DivesToTrip &dives)
|
|||
for (size_t k = i; k < j; ++k)
|
||||
divesInTrip[k - i] = divesMoved[k].d;
|
||||
|
||||
// Check if the from-trip was deleted: If yes, it was recorded in the tripsToAdd structure
|
||||
// Check if the from-trip was deleted: If yes, it was recorded in the tripsToAdd structure.
|
||||
// Only set the flag if this is that last time this trip is featured.
|
||||
bool deleteFrom = from &&
|
||||
std::find_if(dives.tripsToAdd.begin(), dives.tripsToAdd.end(),
|
||||
std::find_if(divesMoved.begin() + j, divesMoved.end(), // Is this the last occurence of "from"?
|
||||
[from](const DiveMoved &entry) { return entry.from == from; }) == divesMoved.end() &&
|
||||
std::find_if(dives.tripsToAdd.begin(), dives.tripsToAdd.end(), // Is "from" in tripsToAdd?
|
||||
[from](const OwningTripPtr &trip) { return trip.get() == from; }) != dives.tripsToAdd.end();
|
||||
// Check if the to-trip has to be created. For this purpose, we saved an array of trips to be created.
|
||||
bool createTo = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue