aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-09-14 19:26:34 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-09-21 16:12:23 -0700
commit067a481b781b09d4f672733550eba987981ea8b6 (patch)
tree0aa57f0046827155d2c6e379501779cef67143ec
parent356293da7d8b457885beca77e48574dd9c73ad5c (diff)
downloadsubsurface-067a481b781b09d4f672733550eba987981ea8b6.tar.gz
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 <bstoeger@mail.tuwien.ac.at>
-rw-r--r--core/trip.c4
-rw-r--r--core/trip.h1
2 files changed, 4 insertions, 1 deletions
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;