aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/cylindermodel.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-08-20 07:31:04 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-08-21 08:48:22 -0700
commitfe3021b88a414b6963891a65b738f52bc41e36a8 (patch)
tree390d1dc9e2fb95171a43b14932a82ea1200578c0 /qt-models/cylindermodel.cpp
parentefc1b4f31ac64d4815d1ab49d9da90dd37c7f3b8 (diff)
downloadsubsurface-fe3021b88a414b6963891a65b738f52bc41e36a8.tar.gz
cleanup: consistently use get_cylinder() accessor
get_cylinder(d, i) is more readable than d->cylinders.cylinders[i]. Moreover, it does bound checking and is more flexible with respect to changing the core data structures. Most places already used this accessor, but some still accessed the cylinders directly. This patch unifies the accesses by consistently switching to get_cylinder(). The affected code is in C++ and accesses the cylinder as reference or object, whereas the get_cylinder() function is C and returns a pointer. This results in funky looking "*get_cylinder(d, i)" expressions. Arguably still better than the original. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/cylindermodel.cpp')
-rw-r--r--qt-models/cylindermodel.cpp4
1 files changed, 2 insertions, 2 deletions
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 {