diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-05-19 14:27:10 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-05-20 21:23:16 -0700 |
commit | 0bc96905bf92de5e7bac88efde181d93d95998f1 (patch) | |
tree | dbfda7a6c615d0b8452bb6ae87e3d98c618df40f /core/dive.c | |
parent | eba6e76b963115a77b5f8607bc6c3ea1040a466f (diff) | |
download | subsurface-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.c | 18 |
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; } /* |