From 014c04f8bd30740e7711f3b3a01619fd27b5b613 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 21 Jul 2018 18:28:33 +0200 Subject: Undo: implement rudimentary support for undo of dive-merging For this, an output-parameter was added to the backend merge_dives() function. When non-zero, instead of adding the merged dive to the preferred trip, the preferred trip is returned to the caller. Since the new UndoObject, just like the delete-dives UndoObject, needs to remove/readd a set of dives, the corresponding functionality was split-off in a helper function. Signed-off-by: Berthold Stoeger --- core/divelist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/divelist.c') diff --git a/core/divelist.c b/core/divelist.c index a25927e90..63bb7aa07 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -26,7 +26,7 @@ * struct dive *unregister_dive(int idx) * void delete_single_dive(int idx) * void add_single_dive(int idx, struct dive *dive) - * void merge_two_dives(struct dive *a, struct dive *b) + * struct dive *merge_two_dives(struct dive *a, struct dive *b) * void select_dive(int idx) * void deselect_dive(int idx) * void mark_divelist_changed(int changed) @@ -1060,7 +1060,7 @@ struct dive *merge_two_dives(struct dive *a, struct dive *b) if (i < 0 || j < 0) // something is wrong with those dives. Bail return NULL; - res = merge_dives(a, b, b->when - a->when, false); + res = merge_dives(a, b, b->when - a->when, false, NULL); if (!res) return NULL; -- cgit v1.2.3-70-g09d2