summaryrefslogtreecommitdiffstats
path: root/core/libdivecomputer.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-03-05 22:58:47 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commite2df38d868324f2a767d2109cdd8727acb866ca2 (patch)
tree614b560431d2c61f3f2b1e2f986c7806bd175ae9 /core/libdivecomputer.c
parentc22fd9f4fd6699333629b8acb1e9c135a9783082 (diff)
downloadsubsurface-e2df38d868324f2a767d2109cdd8727acb866ca2.tar.gz
Dive site: add dive site ref-counting
Instead of setting dive->dive_site directly, call the add_dive_to_dive_site() and unregister_dive_from_dive_site() functions. In the parser this turned out to be a bit tricky. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/libdivecomputer.c')
-rw-r--r--core/libdivecomputer.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c
index 5519afe46..aeca1b94c 100644
--- a/core/libdivecomputer.c
+++ b/core/libdivecomputer.c
@@ -596,8 +596,10 @@ static void parse_string_field(device_data_t *devdata, struct dive *dive, dc_fie
parse_location(line, &location);
- if (location.lat.udeg && location.lon.udeg)
- dive->dive_site = create_dive_site_with_gps(str->value, &location, devdata->sites);
+ if (location.lat.udeg && location.lon.udeg) {
+ unregister_dive_from_dive_site(dive);
+ add_dive_to_dive_site(dive, create_dive_site_with_gps(str->value, &location, devdata->sites));
+ }
}
}
#endif