summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-23 19:11:13 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-29 00:09:31 +0000
commitf527a70831a37e736431baa5705c9d188fc12f4b (patch)
tree5260e51c944b193175b9e318457bb281ee760fdf
parent8de471f90e95a5a75d0fec78d5bbf900eb90f235 (diff)
downloadsubsurface-f527a70831a37e736431baa5705c9d188fc12f4b.tar.gz
Dive site: pass dive-site pointer to delete_dive_site()
Instead of passing a uuid, pass a pointer to the dive site. This is small step in an effort to remove uuids. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--core/divelist.c2
-rw-r--r--core/divesite.c7
-rw-r--r--core/divesite.h2
-rw-r--r--core/save-git.c4
-rw-r--r--core/save-xml.c4
-rw-r--r--core/uemis-downloader.c4
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp2
-rw-r--r--qt-models/divelocationmodel.cpp2
8 files changed, 13 insertions, 14 deletions
diff --git a/core/divelist.c b/core/divelist.c
index d1d326209..6197f23b9 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -1687,7 +1687,7 @@ void clear_dive_file_data()
while (dive_table.nr)
delete_single_dive(0);
while (dive_site_table.nr)
- delete_dive_site(get_dive_site(0)->uuid);
+ delete_dive_site(get_dive_site(0));
clear_dive(&displayed_dive);
diff --git a/core/divesite.c b/core/divesite.c
index 163ecc892..d20421de7 100644
--- a/core/divesite.c
+++ b/core/divesite.c
@@ -172,12 +172,11 @@ void free_dive_site(struct dive_site *ds)
}
}
-void delete_dive_site(uint32_t id)
+void delete_dive_site(struct dive_site *ds)
{
int nr = dive_site_table.nr;
for (int i = 0; i < nr; i++) {
- struct dive_site *ds = get_dive_site(i);
- if (ds->uuid == id) {
+ if (ds == get_dive_site(i)) {
free_dive_site(ds);
if (nr - 1 > i)
memmove(&dive_site_table.dive_sites[i],
@@ -329,7 +328,7 @@ void merge_dive_sites(uint32_t ref, uint32_t* uuids, int count)
for(i = 0; i < count; i++) {
if (uuids[i] == ref)
continue;
- delete_dive_site(uuids[i]);
+ delete_dive_site(get_dive_site_by_uuid(uuids[i]));
}
mark_divelist_changed(true);
}
diff --git a/core/divesite.h b/core/divesite.h
index 2d5c02110..7ea7c53cc 100644
--- a/core/divesite.h
+++ b/core/divesite.h
@@ -57,7 +57,7 @@ struct dive_site *alloc_or_get_dive_site(uint32_t uuid);
int nr_of_dives_at_dive_site(struct dive_site *ds, bool select_only);
bool is_dive_site_used(struct dive_site *ds, bool select_only);
void free_dive_site(struct dive_site *ds);
-void delete_dive_site(uint32_t id);
+void delete_dive_site(struct dive_site *ds);
struct dive_site *create_dive_site(const char *name, timestamp_t divetime);
struct dive_site *create_dive_site_from_current_dive(const char *name);
struct dive_site *create_dive_site_with_gps(const char *name, const location_t *, timestamp_t divetime);
diff --git a/core/save-git.c b/core/save-git.c
index 524c350ed..b118cff3d 100644
--- a/core/save-git.c
+++ b/core/save-git.c
@@ -890,7 +890,7 @@ static void save_divesites(git_repository *repo, struct dir *tree)
if (d->dive_site_uuid == ds->uuid)
d->dive_site_uuid = 0;
}
- delete_dive_site(ds->uuid);
+ delete_dive_site(ds);
i--; // since we just deleted that one
continue;
} else if (ds->name &&
@@ -903,7 +903,7 @@ static void save_divesites(git_repository *repo, struct dir *tree)
if (!is_dive_site_used(ds, false)) {
if (verbose)
fprintf(stderr, "Deleted unused auto-created dive site %s\n", ds->name);
- delete_dive_site(ds->uuid);
+ delete_dive_site(ds);
i--; // since we just deleted that one
continue;
}
diff --git a/core/save-xml.c b/core/save-xml.c
index b4c952468..7393b84cb 100644
--- a/core/save-xml.c
+++ b/core/save-xml.c
@@ -605,7 +605,7 @@ void save_dives_buffer(struct membuffer *b, const bool select_only, bool anonymi
if (d->dive_site_uuid == ds->uuid)
d->dive_site_uuid = 0;
}
- delete_dive_site(ds->uuid);
+ delete_dive_site(ds);
i--; // since we just deleted that one
continue;
} else if (ds->name &&
@@ -617,7 +617,7 @@ void save_dives_buffer(struct membuffer *b, const bool select_only, bool anonymi
if (!is_dive_site_used(ds, false)) {
if (verbose)
fprintf(stderr, "Deleted unused auto-created dive site %s\n", ds->name);
- delete_dive_site(ds->uuid);
+ delete_dive_site(ds);
i--; // since we just deleted that one
continue;
}
diff --git a/core/uemis-downloader.c b/core/uemis-downloader.c
index ce91f9d40..dd111a92a 100644
--- a/core/uemis-downloader.c
+++ b/core/uemis-downloader.c
@@ -1193,7 +1193,7 @@ static void get_uemis_divespot(const char *mountpath, int divespot_id, struct di
if (ods) {
/* if the uuid's are the same, the new site is a duplicate and can be deleted */
if (nds->uuid != ods->uuid) {
- delete_dive_site(nds->uuid);
+ delete_dive_site(nds);
dive->dive_site_uuid = ods->uuid;
}
}
@@ -1202,7 +1202,7 @@ static void get_uemis_divespot(const char *mountpath, int divespot_id, struct di
/* if we can't load the dive site details, delete the site we
* created in process_raw_buffer
*/
- delete_dive_site(dive->dive_site_uuid);
+ delete_dive_site(get_dive_site_by_uuid(dive->dive_site_uuid));
}
}
}
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index 3b727126a..08914c869 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -888,7 +888,7 @@ void MainTab::acceptChanges()
if (oldDs && !is_dive_site_used(oldDs, false)) {
if (verbose)
qDebug() << "delete now unused dive site" << (oldDs->name ? oldDs->name : "without name");
- delete_dive_site(oldDs->uuid);
+ delete_dive_site(oldDs);
MapWidget::instance()->reload();
}
// the code above can change the correct uuid for the displayed dive site - and the
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp
index 5949628b5..43ab8eac7 100644
--- a/qt-models/divelocationmodel.cpp
+++ b/qt-models/divelocationmodel.cpp
@@ -97,7 +97,7 @@ bool LocationInformationModel::removeRows(int row, int, const QModelIndex&)
beginRemoveRows(QModelIndex(), row, row);
struct dive_site *ds = get_dive_site(row);
if (ds)
- delete_dive_site(ds->uuid);
+ delete_dive_site(ds);
endRemoveRows();
return true;
}