mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 23:33:24 +00:00
When saving only selected dives, only include referenced dive sites
The algorithm seems rather brute force; basically quadratic in the number of dives, assuming we have about the same number of dive sites as dives which seems a reasonable assumotion. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d24de5b72b
commit
2365531c68
1 changed files with 13 additions and 2 deletions
15
save-xml.c
15
save-xml.c
|
@ -509,10 +509,10 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
|
|||
/* save the dive sites */
|
||||
put_format(b, "<divesites>\n");
|
||||
for (i = 0; i < dive_site_table.nr; i++) {
|
||||
int j;
|
||||
struct dive *d;
|
||||
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;
|
||||
|
@ -521,6 +521,17 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
|
|||
i--; // since we just deleted that one
|
||||
continue;
|
||||
}
|
||||
if (select_only) {
|
||||
bool found = false;
|
||||
for_each_dive(j, d) {
|
||||
if (d->selected && d->dive_site_uuid == ds->uuid) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
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