From cd22b86bf8cf6c5f521bc9244b4a21537b5fea44 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 3 Oct 2020 10:37:37 +0200 Subject: [PATCH] dive list: when moving dives, delete first and add later When moving dives between trips, the core moves the dives internally and sends a signal to the model. The model adds and removes the dives accordingly. However, when adding the new dive, the old trip hasn't changed its position, so the ordering is wrong leading to an inconsistent state. Therefore, remove the dives first and then readd them. There could still be pathological cases where this fails. However, in the short term this is an improvement. Note that in similar cases, the dives were indeed removed then added, so this case here seems to be an oversight. Signed-off-by: Berthold Stoeger --- qt-models/divetripmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index 539cf98ff..bc2c2ea46 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -1325,8 +1325,8 @@ void DiveTripModelTree::divesMovedBetweenTrips(dive_trip *from, dive_trip *to, b // Cheating! // Unfortunately, removing the dives means that their selection is lost. // Thus, remember the selection and re-add it later. - divesAdded(to, createTo, dives); divesDeletedInternal(from, deleteFrom, dives); // Use internal version to keep current dive + divesAdded(to, createTo, dives); } void DiveTripModelTree::divesTimeChanged(timestamp_t delta, const QVector &dives)