diff --git a/commands/command_pictures.cpp b/commands/command_pictures.cpp index 7abb6349f..0a0e927bc 100644 --- a/commands/command_pictures.cpp +++ b/commands/command_pictures.cpp @@ -171,7 +171,7 @@ AddPictures::AddPictures(const std::vector &pictures) : if (!ds) { // This dive doesn't yet have a dive site -> add a new dive site. QString name = Command::Base::tr("unnamed dive site"); - sitesToAdd.push_back(std::make_unique(qPrintable(name), &it->location)); + sitesToAdd.push_back(std::make_unique(qPrintable(name), it->location)); sitesToSet.push_back({ p.d, sitesToAdd.back().get() }); } else if (!dive_site_has_gps_location(ds)) { // This dive has a dive site, but without coordinates. Let's add them. diff --git a/core/divesite.cpp b/core/divesite.cpp index 8c1ebb8d7..3a6bdf0e6 100644 --- a/core/divesite.cpp +++ b/core/divesite.cpp @@ -41,9 +41,9 @@ dive_site *dive_site_table::get_by_gps(const location_t *loc) const /* to avoid a bug where we have two dive sites with different name and the same GPS coordinates * and first get the gps coordinates (reading a V2 file) and happen to get back "the other" name, * this function allows us to verify if a very specific name/GPS combination already exists */ -dive_site *dive_site_table::get_by_gps_and_name(const std::string &name, const location_t *loc) const +dive_site *dive_site_table::get_by_gps_and_name(const std::string &name, const location_t loc) const { - return get_by_predicate(*this, [&name, loc](const auto &ds) { return ds->location == *loc && + return get_by_predicate(*this, [&name, loc](const auto &ds) { return ds->location == loc && ds->name == name; }); } @@ -93,7 +93,7 @@ dive_site::dive_site(const std::string &name) : name(name) { } -dive_site::dive_site(const std::string &name, const location_t *loc) : name(name), location(*loc) +dive_site::dive_site(const std::string &name, const location_t loc) : name(name), location(loc) { } @@ -134,7 +134,7 @@ dive_site *dive_site_table::create(const std::string &name) } /* same as before, but with GPS data */ -dive_site *dive_site_table::create(const std::string &name, const location_t *loc) +dive_site *dive_site_table::create(const std::string &name, const location_t loc) { return register_site(std::make_unique(name, loc)).ptr; } diff --git a/core/divesite.h b/core/divesite.h index fba9cd7f9..07604cda7 100644 --- a/core/divesite.h +++ b/core/divesite.h @@ -22,7 +22,7 @@ struct dive_site dive_site(); dive_site(const std::string &name); - dive_site(const std::string &name, const location_t *loc); + dive_site(const std::string &name, const location_t loc); dive_site(uint32_t uuid); ~dive_site(); @@ -46,11 +46,11 @@ public: dive_site *get_by_uuid(uint32_t uuid) const; dive_site *alloc_or_get(uint32_t uuid); dive_site *create(const std::string &name); - dive_site *create(const std::string &name, const location_t *); + dive_site *create(const std::string &name, const location_t); dive_site *find_or_create(const std::string &name); dive_site *get_by_name(const std::string &name) const; dive_site *get_by_gps(const location_t *) const; - dive_site *get_by_gps_and_name(const std::string &name, const location_t *) const; + dive_site *get_by_gps_and_name(const std::string &name, const location_t) const; dive_site *get_by_gps_proximity(location_t, int distance) const; dive_site *get_same(const struct dive_site &) const; void purge_empty(); diff --git a/core/libdivecomputer.cpp b/core/libdivecomputer.cpp index 8a5a3a011..35dd4beea 100644 --- a/core/libdivecomputer.cpp +++ b/core/libdivecomputer.cpp @@ -636,7 +636,7 @@ static void parse_string_field(device_data_t *devdata, struct dive *dive, dc_fie if (location.lat.udeg && location.lon.udeg) { unregister_dive_from_dive_site(dive); - devdata->log->sites->create(std::string(str->value), &location)->add_dive(dive); + devdata->log->sites->create(std::string(str->value), location)->add_dive(dive); } } } diff --git a/core/load-git.cpp b/core/load-git.cpp index 2dd8694fb..4a9937b8c 100644 --- a/core/load-git.cpp +++ b/core/load-git.cpp @@ -177,7 +177,7 @@ static void parse_dive_gps(char *line, struct git_parser_state *state) if (!ds) { ds = state->log->sites->get_by_gps(&location); if (!ds) - ds = state->log->sites->create(std::string(), &location); + ds = state->log->sites->create(std::string(), location); ds->add_dive(state->active_dive); } else { if (dive_site_has_gps_location(ds) && ds->location != location) { diff --git a/core/parse-xml.cpp b/core/parse-xml.cpp index 6cbb88350..88f14d0b7 100644 --- a/core/parse-xml.cpp +++ b/core/parse-xml.cpp @@ -1149,7 +1149,7 @@ static void gps_lat(const char *buffer, struct dive *dive, struct parser_state * location.lat = parse_degrees(buffer, &end); if (!ds) { - state->log->sites->create(std::string(), &location)->add_dive(dive); + state->log->sites->create(std::string(), location)->add_dive(dive); } else { if (ds->location.lat.udeg && ds->location.lat.udeg != location.lat.udeg) report_info("Oops, changing the latitude of existing dive site id %8x name %s; not good", ds->uuid, @@ -1166,7 +1166,7 @@ static void gps_long(const char *buffer, struct dive *dive, struct parser_state location.lon = parse_degrees(buffer, &end); if (!ds) { - state->log->sites->create(std::string(), &location)->add_dive(dive); + state->log->sites->create(std::string(), location)->add_dive(dive); } else { if (ds->location.lon.udeg && ds->location.lon.udeg != location.lon.udeg) report_info("Oops, changing the longitude of existing dive site id %8x name %s; not good", ds->uuid, @@ -1204,7 +1204,7 @@ static void gps_in_dive(const char *buffer, struct dive *dive, struct parser_sta // remember the original coordinates so we can create the correct dive site later state->cur_location = location; } else { - ds = state->log->sites->create(std::string(), &location); + ds = state->log->sites->create(std::string(), location); } ds->add_dive(dive); } else { @@ -2225,7 +2225,7 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size, struct divelog *log) /* Measure GPS */ state.cur_location.lat.udeg = (int)((ptr[7] << 24) + (ptr[6] << 16) + (ptr[5] << 8) + (ptr[4] << 0)); state.cur_location.lon.udeg = (int)((ptr[11] << 24) + (ptr[10] << 16) + (ptr[9] << 8) + (ptr[8] << 0)); - state.log->sites->create("DLF imported"s, &state.cur_location)->add_dive(state.cur_dive); + state.log->sites->create("DLF imported"s, state.cur_location)->add_dive(state.cur_dive); break; default: break; diff --git a/core/parse.cpp b/core/parse.cpp index c0f0e57e6..be797a288 100644 --- a/core/parse.cpp +++ b/core/parse.cpp @@ -481,7 +481,7 @@ void add_dive_site(const char *ds_name, struct dive *dive, struct parser_state * // but wait, we could have gotten this one based on GPS coords and could // have had two different names for the same site... so let's search the other // way around - struct dive_site *exact_match = state->log->sites->get_by_gps_and_name(trimmed, &ds->location); + struct dive_site *exact_match = state->log->sites->get_by_gps_and_name(trimmed, ds->location); if (exact_match) { unregister_dive_from_dive_site(dive); exact_match->add_dive(dive); diff --git a/smtk-import/smartrak.cpp b/smtk-import/smartrak.cpp index bac514a45..e0618d860 100644 --- a/smtk-import/smartrak.cpp +++ b/smtk-import/smartrak.cpp @@ -428,7 +428,7 @@ static void smtk_build_location(MdbHandle *mdb, char *idx, struct dive_site **lo if (!has_location(&loc)) ds = log->sites->create(str); else - ds = log->sites->create(str, &loc); + ds = log->sites->create(str, loc); } *location = ds;