diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/gpslocation.cpp | 4 | ||||
-rw-r--r-- | core/load-git.c | 4 | ||||
-rw-r--r-- | core/parse-xml.c | 4 | ||||
-rw-r--r-- | core/qthelper.cpp | 2 | ||||
-rw-r--r-- | core/qthelper.h | 2 | ||||
-rw-r--r-- | core/subsurface-qt/DiveObjectHelper.cpp | 7 |
6 files changed, 15 insertions, 8 deletions
diff --git a/core/gpslocation.cpp b/core/gpslocation.cpp index e0b176f58..d0bbcdc8f 100644 --- a/core/gpslocation.cpp +++ b/core/gpslocation.cpp @@ -137,7 +137,9 @@ QString GpsLocation::currentPosition() if (delta < 300) { // we can simply use the last position that we tracked gpsTracker gt = m_trackers.last(); - QString gpsString = printGPSCoords(>.location); + char *gps = printGPSCoords(>.location); + QString gpsString = gps; + free(gps); qDebug() << "returning last position" << gpsString; return gpsString; } else { diff --git a/core/load-git.c b/core/load-git.c index 08d9b7765..8417fc2e4 100644 --- a/core/load-git.c +++ b/core/load-git.c @@ -164,10 +164,10 @@ static void parse_dive_gps(char *line, struct membuffer *str, void *_dive) dive->dive_site = ds; } else { if (dive_site_has_gps_location(ds) && !same_location(&ds->location, &location)) { - const char *coords = printGPSCoords(&location); + char *coords = printGPSCoords(&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((void *)coords); + free(coords); } ds->location = location; } diff --git a/core/parse-xml.c b/core/parse-xml.c index c2e2ef937..c118c89cc 100644 --- a/core/parse-xml.c +++ b/core/parse-xml.c @@ -1201,9 +1201,9 @@ static void gps_in_dive(char *buffer, struct dive *dive, struct parser_state *st 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); - const char *coords = printGPSCoords(&location); + char *coords = printGPSCoords(&location); ds->notes = add_to_string(ds->notes, translate("gettextFromC", "multiple GPS locations for this dive site; also %s\n"), coords); - free((void *)coords); + free(coords); } else { ds->location = location; } diff --git a/core/qthelper.cpp b/core/qthelper.cpp index 89dd1befb..26a8a68f9 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -72,7 +72,7 @@ QString distance_string(int distanceInMeters) return str; } -extern "C" const char *printGPSCoords(const location_t *location) +extern "C" char *printGPSCoords(const location_t *location) { int lat = location->lat.udeg; int lon = location->lon.udeg; diff --git a/core/qthelper.h b/core/qthelper.h index 3e90a1979..ed09d70fb 100644 --- a/core/qthelper.h +++ b/core/qthelper.h @@ -123,7 +123,7 @@ void moveInVector(Vector &v, int rangeBegin, int rangeEnd, int destination) extern "C" { #endif -const char *printGPSCoords(const location_t *loc); +char *printGPSCoords(const location_t *loc); bool in_planner(); bool getProxyString(char **buffer); bool canReachCloudServer(); diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp index 0742e382f..921d55bea 100644 --- a/core/subsurface-qt/DiveObjectHelper.cpp +++ b/core/subsurface-qt/DiveObjectHelper.cpp @@ -112,7 +112,12 @@ QString DiveObjectHelper::location() const QString DiveObjectHelper::gps() const { struct dive_site *ds = m_dive->dive_site; - return ds ? QString(printGPSCoords(&ds->location)) : QString(); + if (!ds) + return QString(); + char *gps = printGPSCoords(&ds->location); + QString res = gps; + free(gps); + return res; } QString DiveObjectHelper::gps_decimal() const |