mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 00:13:24 +00:00
Don't store empty dive sites
And remove references to them from the dives. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
ca72ab5749
commit
6820b13bd5
2 changed files with 22 additions and 0 deletions
11
save-git.c
11
save-git.c
|
@ -827,6 +827,17 @@ static void save_divesites(git_repository *repo, struct dir *tree)
|
|||
for (int i = 0; i < dive_site_table.nr; i++) {
|
||||
struct membuffer b = { 0 };
|
||||
struct dive_site *ds = get_dive_site(i);
|
||||
if (dive_site_is_empty(ds)) {
|
||||
int j;
|
||||
struct dive *d;
|
||||
for_each_dive(j, d) {
|
||||
if (d->dive_site_uuid == ds->uuid)
|
||||
d->dive_site_uuid = 0;
|
||||
}
|
||||
delete_dive_site(get_dive_site(i)->uuid);
|
||||
i--; // since we just deleted that one
|
||||
continue;
|
||||
}
|
||||
int size = sizeof("Site-012345678");
|
||||
char name[size];
|
||||
snprintf(name, size, "Site-%08x", ds->uuid);
|
||||
|
|
11
save-xml.c
11
save-xml.c
|
@ -506,6 +506,17 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
|
|||
put_format(b, "<divesites>\n");
|
||||
for (i = 0; i < dive_site_table.nr; i++) {
|
||||
struct dive_site *ds = get_dive_site(i);
|
||||
if (dive_site_is_empty(ds)) {
|
||||
int j;
|
||||
struct dive *d;
|
||||
for_each_dive(j, d) {
|
||||
if (d->dive_site_uuid == ds->uuid)
|
||||
d->dive_site_uuid = 0;
|
||||
}
|
||||
delete_dive_site(get_dive_site(i)->uuid);
|
||||
i--; // since we just deleted that one
|
||||
continue;
|
||||
}
|
||||
put_format(b, "<site uuid='%8x' ", ds->uuid);
|
||||
show_utf8(b, ds->name, " name='", "'", 1);
|
||||
if (ds->latitude.udeg || ds->longitude.udeg) {
|
||||
|
|
Loading…
Add table
Reference in a new issue