aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-01 21:00:38 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-01 21:12:14 -0400
commit7d8a36820d9db03956191cfe8f10087d93bf17b5 (patch)
tree10144ad9dbdd83fc9aeee9cdb101094be92bba15
parent12c83b744edd9abe0b8e0f1ca7577871be95dbca (diff)
downloadsubsurface-7d8a36820d9db03956191cfe8f10087d93bf17b5.tar.gz
Avoid memory leaks
Coverity CID 1308003 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/locationinformation.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp
index c03b0e869..11dc53220 100644
--- a/qt-ui/locationinformation.cpp
+++ b/qt-ui/locationinformation.cpp
@@ -102,11 +102,13 @@ void LocationInformationWidget::updateLabels()
ui.diveSiteNotes->setPlainText(displayed_dive_site.notes);
else
ui.diveSiteNotes->clear();
- if (displayed_dive_site.latitude.udeg || displayed_dive_site.longitude.udeg)
- ui.diveSiteCoordinates->setText(printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg));
- else
+ if (displayed_dive_site.latitude.udeg || displayed_dive_site.longitude.udeg) {
+ const char *coords = printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg);
+ ui.diveSiteCoordinates->setText(coords);
+ free((void *)coords);
+ } else {
ui.diveSiteCoordinates->clear();
-
+ }
emit startFilterDiveSite(displayed_dive_site.uuid);
emit startEditDiveSite(displayed_dive_site.uuid);
}
@@ -114,7 +116,9 @@ void LocationInformationWidget::updateLabels()
void LocationInformationWidget::updateGpsCoordinates()
{
QString oldText = ui.diveSiteCoordinates->text();
- ui.diveSiteCoordinates->setText(printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg));
+ const char *coords = printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg);
+ ui.diveSiteCoordinates->setText(coords);
+ free((void *)coords);
if (oldText != ui.diveSiteCoordinates->text())
markChangedWidget(ui.diveSiteCoordinates);
}
@@ -220,7 +224,8 @@ void LocationInformationWidget::on_diveSiteCoordinates_textChanged(const QString
{
uint lat = displayed_dive_site.latitude.udeg;
uint lon = displayed_dive_site.longitude.udeg;
- if (!same_string(qPrintable(text), printGPSCoords(lat, lon))) {
+ const char *coords = printGPSCoords(lat, lon);
+ if (!same_string(qPrintable(text), coords)) {
double latitude, longitude;
if (parseGpsText(text, &latitude, &longitude)) {
displayed_dive_site.latitude.udeg = latitude * 1000000;
@@ -229,6 +234,7 @@ void LocationInformationWidget::on_diveSiteCoordinates_textChanged(const QString
emit coordinatesChanged();
}
}
+ free((void *)coords);
}
void LocationInformationWidget::on_diveSiteDescription_textChanged(const QString &text)