summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/command_edit.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-06-29 10:27:48 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-11-09 19:19:04 +0100
commit77e5dbac7309d6bc09d6ef2631857d41486f3ac8 (patch)
tree252c5ad131932ed954e09462eb766088dfe06ef8 /desktop-widgets/command_edit.cpp
parent16bdbc54b9b1966c03745ec54aa75a893ee89f16 (diff)
downloadsubsurface-77e5dbac7309d6bc09d6ef2631857d41486f3ac8.tar.gz
Undo: Make PasteState cylinders list dynamically allocated
Instead of using a sub-array, use a std::vector<>. This is a necessary step in removing the MAX_CYLINDERS restriction. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/command_edit.cpp')
-rw-r--r--desktop-widgets/command_edit.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/desktop-widgets/command_edit.cpp b/desktop-widgets/command_edit.cpp
index 5f6f0be3f..95665722d 100644
--- a/desktop-widgets/command_edit.cpp
+++ b/desktop-widgets/command_edit.cpp
@@ -687,7 +687,8 @@ static void swapCandQString(QString &q, char *&c)
}
PasteState::PasteState(dive *dIn, const dive *data, dive_components what) : d(dIn),
- tags(nullptr)
+ tags(nullptr),
+ cylinders(MAX_CYLINDERS)
{
memset(&cylinders[0], 0, sizeof(cylinders));
memset(&weightsystems, 0, sizeof(weightsystems));
@@ -742,8 +743,10 @@ void PasteState::swap(dive_components what)
std::swap(divesite, d->dive_site);
if (what.tags)
std::swap(tags, d->tag_list);
- if (what.cylinders)
- std::swap(cylinders, d->cylinder);
+ if (what.cylinders) {
+ for (int i = 0; i < MAX_CYLINDERS; ++i)
+ std::swap(cylinders[i], d->cylinder[i]);
+ }
if (what.weights)
std::swap(weightsystems, d->weightsystems);
}