aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-05-05 11:34:16 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-06 11:44:22 -0700
commitbeef8096f7d3f580804a30a55364b057897dfcb3 (patch)
tree256830e1041636cac940567fd822420974bc5125 /commands
parent862fcdf8ea5b2a25f25b018cf870cd09d71fc93d (diff)
downloadsubsurface-beef8096f7d3f580804a30a55364b057897dfcb3.tar.gz
undo: update cylinder related info when editing cylinder data
We have to call update_cylinder_related_info() when adding / editing / removing cylinders. This could be done in a common base class of the commands. For simplicity, let's call the function in the respective undo()/redo() functions. Partially fixes #2814. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'commands')
-rw-r--r--commands/command_edit.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/commands/command_edit.cpp b/commands/command_edit.cpp
index c763cbffa..248a8e08a 100644
--- a/commands/command_edit.cpp
+++ b/commands/command_edit.cpp
@@ -1061,6 +1061,7 @@ void AddCylinder::undo()
if (d->cylinders.nr <= 0)
continue;
remove_cylinder(d, d->cylinders.nr - 1);
+ update_cylinder_related_info(d);
emit diveListNotifier.cylinderRemoved(d, d->cylinders.nr);
invalidate_dive_cache(d); // Ensure that dive is written in git_save()
}
@@ -1070,6 +1071,7 @@ void AddCylinder::redo()
{
for (dive *d: dives) {
add_cloned_cylinder(&d->cylinders, cyl);
+ update_cylinder_related_info(d);
emit diveListNotifier.cylinderAdded(d, d->cylinders.nr - 1);
invalidate_dive_cache(d); // Ensure that dive is written in git_save()
}
@@ -1168,6 +1170,7 @@ void RemoveCylinder::undo()
for (size_t i = 0; i < dives.size(); ++i) {
std::vector<int> mapping = get_cylinder_map_for_add(dives[i]->cylinders.nr, indexes[i]);
add_cylinder(&dives[i]->cylinders, indexes[i], clone_cylinder(cyl[i]));
+ update_cylinder_related_info(dives[i]);
emit diveListNotifier.cylinderAdded(dives[i], indexes[i]);
invalidate_dive_cache(dives[i]); // Ensure that dive is written in git_save()
}
@@ -1179,6 +1182,7 @@ void RemoveCylinder::redo()
std::vector<int> mapping = get_cylinder_map_for_remove(dives[i]->cylinders.nr, indexes[i]);
remove_cylinder(dives[i], indexes[i]);
cylinder_renumber(dives[i], &mapping[0]);
+ update_cylinder_related_info(dives[i]);
emit diveListNotifier.cylinderRemoved(dives[i], indexes[i]);
invalidate_dive_cache(dives[i]); // Ensure that dive is written in git_save()
}
@@ -1255,6 +1259,7 @@ void EditCylinder::redo()
{
for (size_t i = 0; i < dives.size(); ++i) {
std::swap(dives[i]->cylinders.cylinders[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()
}