summaryrefslogtreecommitdiffstats
path: root/core/dive.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-05-19 14:27:10 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-05-20 21:23:16 -0700
commit0bc96905bf92de5e7bac88efde181d93d95998f1 (patch)
treedbfda7a6c615d0b8452bb6ae87e3d98c618df40f /core/dive.c
parenteba6e76b963115a77b5f8607bc6c3ea1040a466f (diff)
downloadsubsurface-0bc96905bf92de5e7bac88efde181d93d95998f1.tar.gz
Undo: make "delete dive computer" undoable
Simply reuse the code for "move dive computer" by creating a DiveComputerBase base class. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/dive.c')
-rw-r--r--core/dive.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/core/dive.c b/core/dive.c
index e6b27e0bb..b8162edd0 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -4234,10 +4234,22 @@ static void delete_divecomputer(struct dive *d, int num)
invalidate_dive_cache(d);
}
-/* always acts on the current dive */
-void delete_current_divecomputer(void)
+/* Clone a dive and delete goven dive computer */
+struct dive *clone_delete_divecomputer(const struct dive *d, int dc_number)
{
- delete_divecomputer(current_dive, dc_number);
+ struct dive *res;
+
+ /* copy the dive */
+ res = alloc_dive();
+ copy_dive(d, res);
+
+ /* make a new unique id, since we still can't handle two equal ids */
+ res->id = dive_getUniqID();
+ invalidate_dive_cache(res);
+
+ delete_divecomputer(res, dc_number);
+
+ return res;
}
/*