mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Locationinformation: correctly handle strings on the heap
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
53c503dc35
commit
20f42e7aa8
1 changed files with 16 additions and 7 deletions
|
@ -142,7 +142,7 @@ void LocationInformationWidget::acceptChanges()
|
|||
{
|
||||
char *uiString;
|
||||
struct dive_site *currentDs;
|
||||
uiString = ui.diveSiteName->text().toUtf8().data();
|
||||
uiString = copy_string(ui.diveSiteName->text().toUtf8().data());
|
||||
if (get_dive_site_by_uuid(displayed_dive_site.uuid) != NULL) {
|
||||
currentDs = get_dive_site_by_uuid(displayed_dive_site.uuid);
|
||||
} else {
|
||||
|
@ -154,27 +154,36 @@ void LocationInformationWidget::acceptChanges()
|
|||
currentDs->longitude = displayed_dive_site.longitude;
|
||||
if (!same_string(uiString, currentDs->name)) {
|
||||
free(currentDs->name);
|
||||
currentDs->name = copy_string(uiString);
|
||||
currentDs->name = uiString;
|
||||
} else {
|
||||
free(uiString);
|
||||
}
|
||||
uiString = ui.diveSiteDescription->text().toUtf8().data();
|
||||
uiString = copy_string(ui.diveSiteDescription->text().toUtf8().data());
|
||||
if (!same_string(uiString, currentDs->description)) {
|
||||
free(currentDs->description);
|
||||
currentDs->description = copy_string(uiString);
|
||||
currentDs->description = uiString;
|
||||
} else {
|
||||
free(uiString);
|
||||
}
|
||||
uiString = copy_string(ui.diveSiteCountry->text().toUtf8().data());
|
||||
// if the user entered a different contriy, first update the taxonomy
|
||||
// for the displayed dive site; this below will get copied into the currentDs
|
||||
if (!same_string(uiString, taxonomy_get_country(&displayed_dive_site.taxonomy)) &&
|
||||
!same_string(uiString, ""))
|
||||
taxonomy_set_country(&displayed_dive_site.taxonomy, copy_string(uiString), taxonomy_origin::GEOMANUAL);
|
||||
taxonomy_set_country(&displayed_dive_site.taxonomy, uiString, taxonomy_origin::GEOMANUAL);
|
||||
else
|
||||
free(uiString);
|
||||
// now update the currentDs (which we then later copy back ontop of displayed_dive_site
|
||||
copy_dive_site_taxonomy(&displayed_dive_site, currentDs);
|
||||
|
||||
uiString = ui.diveSiteNotes->document()->toPlainText().toUtf8().data();
|
||||
uiString = copy_string(ui.diveSiteNotes->document()->toPlainText().toUtf8().data());
|
||||
if (!same_string(uiString, currentDs->notes)) {
|
||||
free(currentDs->notes);
|
||||
currentDs->notes = copy_string(uiString);
|
||||
currentDs->notes = uiString;
|
||||
} else {
|
||||
free(uiString);
|
||||
}
|
||||
|
||||
if (!ui.diveSiteCoordinates->text().isEmpty()) {
|
||||
double lat, lon;
|
||||
parseGpsText(ui.diveSiteCoordinates->text(), &lat, &lon);
|
||||
|
|
Loading…
Add table
Reference in a new issue