mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Core: introduce insert_trip_dont_merge() function
insert_trip() adds a trip to the backend, but merges trips if there exists a trip with the same date. This is a disaster for the MergeTrips command, because this command adds a new trip and removes the previous two. Of course if the added trip is merged, this cannot work. Therefore, add an insert_trip_dont_merge() function, which adds the trip, but doesn't merge. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
43c3885249
commit
6ac4ddbeed
3 changed files with 22 additions and 8 deletions
|
@ -422,6 +422,7 @@ extern int dive_get_insertion_index(struct dive *dive);
|
|||
extern void add_single_dive(int idx, struct dive *dive);
|
||||
|
||||
extern void insert_trip(dive_trip_t **trip);
|
||||
extern void insert_trip_dont_merge(dive_trip_t *trip);
|
||||
extern void unregister_trip(dive_trip_t *trip);
|
||||
extern void free_trip(dive_trip_t *trip);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* void update_cylinder_related_info(struct dive *dive)
|
||||
* void dump_trip_list(void)
|
||||
* void insert_trip(dive_trip_t **dive_trip_p)
|
||||
* void insert_trip_dont_merge(dive_trip_t *dive_trip_p)
|
||||
* void unregister_trip(dive_trip_t *trip)
|
||||
* void free_trip(dive_trip_t *trip)
|
||||
* void remove_dive_from_trip(struct dive *dive)
|
||||
|
@ -739,6 +740,22 @@ void insert_trip(dive_trip_t **dive_trip_p)
|
|||
#endif
|
||||
}
|
||||
|
||||
/* same as insert_trip, but don't merge trips with the same date.
|
||||
* this is cruical for the merge undo-command, because there we
|
||||
* add a new trip with the same date and then remove the old one. */
|
||||
void insert_trip_dont_merge(dive_trip_t *dive_trip)
|
||||
{
|
||||
dive_trip_t **p = &dive_trip_list;
|
||||
dive_trip_t *trip;
|
||||
|
||||
/* Walk the dive trip list looking for the right location.. */
|
||||
while ((trip = *p) != NULL && trip->when < dive_trip->when)
|
||||
p = &trip->next;
|
||||
|
||||
dive_trip->next = trip;
|
||||
*p = dive_trip;
|
||||
}
|
||||
|
||||
/* free resources associated with a trip structure */
|
||||
void free_trip(dive_trip_t *trip)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue