From 067a481b781b09d4f672733550eba987981ea8b6 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 14 Sep 2019 19:26:34 +0200 Subject: Core: add unique id to trip To make it easier to pass around trips through QML, give each trip a unique id. The id is generated in alloc_trip() and uses the same function to generate unique dive ids. Signed-off-by: Berthold Stoeger --- core/trip.c | 4 +++- core/trip.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/trip.c b/core/trip.c index bc9b1b5a9..c4534fe27 100644 --- a/core/trip.c +++ b/core/trip.c @@ -122,7 +122,9 @@ void remove_dive_from_trip(struct dive *dive, struct trip_table *trip_table_arg) dive_trip_t *alloc_trip(void) { - return calloc(1, sizeof(dive_trip_t)); + dive_trip_t *res = calloc(1, sizeof(dive_trip_t)); + res->id = dive_getUniqID(); + return res; } /* insert the trip into the trip table */ diff --git a/core/trip.h b/core/trip.h index 2ca2791cd..51f371589 100644 --- a/core/trip.h +++ b/core/trip.h @@ -13,6 +13,7 @@ typedef struct dive_trip char *location; char *notes; struct dive_table dives; + int id; /* unique ID for this trip: used to pass trips through QML. */ /* Used by the io-routines to mark trips that have already been written. */ bool saved; bool autogen; -- cgit v1.2.3-70-g09d2