Undo: properly reference-count dive sites
Recently, the undo code was changed to consider dive sites. The undo code uses a DiveToAdd structure, which was extended by the dive site to which the dive should be added. The split and merge commands were not adapted and therefore the dive counts of the dive sites were wrong after split and merge. Fix this by properly setting the dive site field and removing the reference in the dive structure (in the split case, the merge case already cleared the reference). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
77b5d714fb
commit
3debd92734
@ -727,12 +727,20 @@ SplitDivesBase::SplitDivesBase(dive *d, std::array<dive *, 2> newDives)
|
||||
newDives[0]->selected = false;
|
||||
newDives[1]->selected = false;
|
||||
|
||||
// The new dives will be registered to the dive site using the site member
|
||||
// of the DiveToAdd structure. For this to work, we must set the dive's
|
||||
// dive_site member to null. Yes, that's subtle!
|
||||
newDives[0]->dive_site = nullptr;
|
||||
newDives[1]->dive_site = nullptr;
|
||||
|
||||
diveToSplit.dives.push_back(d);
|
||||
splitDives.dives.resize(2);
|
||||
splitDives.dives[0].dive.reset(newDives[0]);
|
||||
splitDives.dives[0].trip = d->divetrip;
|
||||
splitDives.dives[0].site = d->dive_site;
|
||||
splitDives.dives[1].dive.reset(newDives[1]);
|
||||
splitDives.dives[1].trip = d->divetrip;
|
||||
splitDives.dives[1].site = d->dive_site;
|
||||
}
|
||||
|
||||
bool SplitDivesBase::workToBeDone()
|
||||
@ -875,6 +883,7 @@ MergeDives::MergeDives(const QVector <dive *> &dives)
|
||||
mergedDive.dives.resize(1);
|
||||
mergedDive.dives[0].dive = std::move(d);
|
||||
mergedDive.dives[0].trip = preferred_trip;
|
||||
mergedDive.dives[0].site = preferred_site;
|
||||
divesToMerge.dives = dives.toStdVector();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user