summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/command_edit.cpp10
-rw-r--r--core/fulltext.cpp2
-rw-r--r--qt-models/cylindermodel.cpp4
-rw-r--r--qt-models/divesummarymodel.cpp2
4 files changed, 9 insertions, 9 deletions
diff --git a/commands/command_edit.cpp b/commands/command_edit.cpp
index 248a8e08a..ae97594e4 100644
--- a/commands/command_edit.cpp
+++ b/commands/command_edit.cpp
@@ -668,7 +668,7 @@ PasteState::PasteState(dive *dIn, const dive *data, dive_components what) : d(dI
// 2) For cylinders that do not yet exist in the destination dive, we set the pressures to 0, i.e. unset.
// Moreover, for these we set the manually_added flag, because they weren't downloaded from a DC.
for (int i = 0; i < d->cylinders.nr && i < cylinders.nr; ++i) {
- const cylinder_t &src = d->cylinders.cylinders[i];
+ const cylinder_t &src = *get_cylinder(d, i);
cylinder_t &dst = cylinders.cylinders[i];
dst.gasmix = src.gasmix;
dst.start = src.start;
@@ -1112,7 +1112,7 @@ static bool same_cylinder_with_flags(const cylinder_t &cyl1, const cylinder_t &c
static int find_cylinder_index(const struct dive *d, const cylinder_t &cyl, int sameCylinderFlags)
{
for (int idx = 0; idx < d->cylinders.nr; ++idx) {
- if (same_cylinder_with_flags(cyl, d->cylinders.cylinders[idx], sameCylinderFlags))
+ if (same_cylinder_with_flags(cyl, *get_cylinder(d, idx), sameCylinderFlags))
return idx;
}
return -1;
@@ -1126,7 +1126,7 @@ EditCylinderBase::EditCylinderBase(int index, bool currentDiveOnly, bool nonProt
dives.clear();
return;
}
- const cylinder_t &orig = current->cylinders.cylinders[index];
+ const cylinder_t &orig = *get_cylinder(current, index);
std::vector<dive *> divesNew;
divesNew.reserve(dives.size());
@@ -1139,7 +1139,7 @@ EditCylinderBase::EditCylinderBase(int index, bool currentDiveOnly, bool nonProt
continue;
divesNew.push_back(d);
indexes.push_back(idx);
- cyl.push_back(clone_cylinder(d->cylinders.cylinders[idx]));
+ cyl.push_back(clone_cylinder(*get_cylinder(d, idx)));
}
dives = std::move(divesNew);
}
@@ -1258,7 +1258,7 @@ EditCylinder::EditCylinder(int index, cylinder_t cylIn, EditCylinderType typeIn,
void EditCylinder::redo()
{
for (size_t i = 0; i < dives.size(); ++i) {
- std::swap(dives[i]->cylinders.cylinders[indexes[i]], cyl[i]);
+ std::swap(*get_cylinder(dives[i], indexes[i]), cyl[i]);
update_cylinder_related_info(dives[i]);
emit diveListNotifier.cylinderEdited(dives[i], indexes[i]);
invalidate_dive_cache(dives[i]); // Ensure that dive is written in git_save()
diff --git a/core/fulltext.cpp b/core/fulltext.cpp
index 2e27d8524..9dc6d826c 100644
--- a/core/fulltext.cpp
+++ b/core/fulltext.cpp
@@ -127,7 +127,7 @@ static std::vector<QString> getWords(const dive *d)
for (const tag_entry *tag = d->tag_list; tag; tag = tag->next)
tokenize(QString(tag->tag->name), res);
for (int i = 0; i < d->cylinders.nr; ++i) {
- const cylinder_t &cyl = d->cylinders.cylinders[i];
+ const cylinder_t &cyl = *get_cylinder(d, i);
tokenize(QString(cyl.type.description), res);
}
for (int i = 0; i < d->weightsystems.nr; ++i) {
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp
index 84e9b063f..f8612c48d 100644
--- a/qt-models/cylindermodel.cpp
+++ b/qt-models/cylindermodel.cpp
@@ -357,7 +357,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
// First, we make a shallow copy of the old cylinder. Then we modify the fields inside that copy.
// At the end, we either place an EditCylinder undo command (EquipmentTab) or copy the cylinder back (planner).
// Yes, this is not ideal, but the pragmatic thing to do for now.
- cylinder_t cyl = d->cylinders.cylinders[row];
+ cylinder_t cyl = *get_cylinder(d, row);
if (index.column() != TYPE && !changed)
return false;
@@ -467,7 +467,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
// In the planner - simply overwrite the cylinder in the dive with the modified cylinder.
// We have only made a shallow copy, therefore copy the new cylinder first.
cylinder_t copy = clone_cylinder(cyl);
- std::swap(copy, d->cylinders.cylinders[row]);
+ std::swap(copy, *get_cylinder(d, row));
free_cylinder(copy);
dataChanged(index, index);
} else {
diff --git a/qt-models/divesummarymodel.cpp b/qt-models/divesummarymodel.cpp
index d187f2b58..6ae5313e4 100644
--- a/qt-models/divesummarymodel.cpp
+++ b/qt-models/divesummarymodel.cpp
@@ -148,7 +148,7 @@ static void calculateDive(struct dive *dive, Stats &stats)
// EAN dive ?
for (int j = 0; j < dive->cylinders.nr; ++j) {
- if (dive->cylinders.cylinders[j].gasmix.o2.permille > 210) {
+ if (get_cylinder(dive, j)->gasmix.o2.permille > 210) {
stats.divesEAN++;
break;
}