Correctly create a dive site with the name entered on the Notes tab

The char pointer was out of scope by the time we created the dive site.
Also remove the misleading comment above - it really makes sense to do
nothing in that function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-03-16 10:50:25 -07:00
parent 0d77b921eb
commit 84aab5ffed

View file

@ -1114,18 +1114,6 @@ void MainTab::on_location_textChanged(const QString &text)
if (currentTrip) { if (currentTrip) {
free(displayedTrip.location); free(displayedTrip.location);
displayedTrip.location = strdup(ui.location->text().toUtf8().data()); displayedTrip.location = strdup(ui.location->text().toUtf8().data());
} else {
// this means we switched dive sites... this requires a lot more thinking
//
//
// FIXME
//
// TODO
//
//
//
// free(displayed_dive.location);
// displayed_dive.location = strdup(ui.location->text().toUtf8().data());
} }
markChangedWidget(ui.location); markChangedWidget(ui.location);
} }
@ -1134,11 +1122,12 @@ void MainTab::on_location_textChanged(const QString &text)
void MainTab::on_location_editingFinished() void MainTab::on_location_editingFinished()
{ {
// find the dive site or create it // find the dive site or create it
const char *name = ui.location->text().toUtf8().data(); const char *name = copy_string(qPrintable(ui.location->text()));
uint32_t uuid = get_dive_site_uuid_by_name(name, NULL); uint32_t uuid = get_dive_site_uuid_by_name(name, NULL);
if (!uuid) if (!uuid)
uuid = create_dive_site(name); uuid = create_dive_site(name);
displayed_dive.dive_site_uuid = uuid; displayed_dive.dive_site_uuid = uuid;
free((void*)name);
} }
void MainTab::on_suit_textChanged(const QString &text) void MainTab::on_suit_textChanged(const QString &text)