diff --git a/core/load-git.cpp b/core/load-git.cpp index 8818105cb..41c166aeb 100644 --- a/core/load-git.cpp +++ b/core/load-git.cpp @@ -181,10 +181,9 @@ static void parse_dive_gps(char *line, struct membuffer *, struct git_parser_sta add_dive_to_dive_site(state->active_dive, ds); } else { if (dive_site_has_gps_location(ds) && !same_location(&ds->location, &location)) { - char *coords = printGPSCoordsC(&location); + std::string coords = printGPSCoordsC(&location); // we have a dive site that already has GPS coordinates - ds->notes = add_to_string(ds->notes, translate("gettextFromC", "multiple GPS locations for this dive site; also %s\n"), coords); - free(coords); + ds->notes = add_to_string(ds->notes, translate("gettextFromC", "multiple GPS locations for this dive site; also %s\n"), coords.c_str()); } ds->location = location; } diff --git a/core/parse-xml.cpp b/core/parse-xml.cpp index eb2364003..d516ab5ec 100644 --- a/core/parse-xml.cpp +++ b/core/parse-xml.cpp @@ -1230,9 +1230,8 @@ static void gps_in_dive(const char *buffer, struct dive *dive, struct parser_sta fprintf(stderr, "dive site uuid in dive, but gps location (%10.6f/%10.6f) different from dive location (%10.6f/%10.6f)\n", ds->location.lat.udeg / 1000000.0, ds->location.lon.udeg / 1000000.0, location.lat.udeg / 1000000.0, location.lon.udeg / 1000000.0); - char *coords = printGPSCoordsC(&location); - ds->notes = add_to_string(ds->notes, translate("gettextFromC", "multiple GPS locations for this dive site; also %s\n"), coords); - free(coords); + std::string coords = printGPSCoordsC(&location); + ds->notes = add_to_string(ds->notes, translate("gettextFromC", "multiple GPS locations for this dive site; also %s\n"), coords.c_str()); } else { ds->location = location; } diff --git a/core/qthelper.cpp b/core/qthelper.cpp index f1077a762..ab6ce5389 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -115,9 +115,9 @@ QString printGPSCoords(const location_t *location) return result; } -extern "C" char *printGPSCoordsC(const location_t *location) +std::string printGPSCoordsC(const location_t *location) { - return copy_qstring(printGPSCoords(location)); + return printGPSCoords(location).toStdString(); } /** diff --git a/core/qthelper.h b/core/qthelper.h index 12eb24f7d..0ad4254f1 100644 --- a/core/qthelper.h +++ b/core/qthelper.h @@ -93,6 +93,7 @@ QLocale getLocale(); QVector> selectedDivesGasUsed(); QString getUserAgent(); QString printGPSCoords(const location_t *loc); +std::string printGPSCoordsC(const location_t *loc); std::vector get_cylinder_map_for_remove(int count, int n); std::vector get_cylinder_map_for_add(int count, int n); @@ -118,7 +119,6 @@ extern "C" { struct git_info; -char *printGPSCoordsC(const location_t *loc); bool getProxyString(char **buffer); bool canReachCloudServer(struct git_info *); void updateWindowTitle();