Don't add empty dive sites

It makes no sense to keep them around, it makes no sense to have dives
refer to them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-02-13 23:08:33 -08:00
parent 7ca3d859dc
commit 3ea2e15bd2

View file

@ -708,6 +708,13 @@ void LocationInformationWidget::acceptChanges()
free(currentDs->notes);
currentDs->notes = copy_string(uiString);
}
if (dive_site_is_empty(currentDs)) {
delete_dive_site(currentDs->uuid);
displayed_dive.dive_site_uuid = 0;
setLocationId(0);
} else {
setLocationId(currentDs->uuid);
}
mark_divelist_changed(true);
emit informationManagementEnded();
}
@ -715,7 +722,13 @@ void LocationInformationWidget::acceptChanges()
void LocationInformationWidget::rejectChanges()
{
Q_ASSERT(currentDs != NULL);
setLocationId(currentDs->uuid);
if (dive_site_is_empty(currentDs)) {
delete_dive_site(currentDs->uuid);
displayed_dive.dive_site_uuid = 0;
setLocationId(0);
} else {
setLocationId(currentDs->uuid);
}
emit informationManagementEnded();
}