From 3ea2e15bd2f20e0f84bf02a468c3273a347ac554 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 13 Feb 2015 23:08:33 -0800 Subject: 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 --- qt-ui/simplewidgets.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index f32ce9b19..27050f6e2 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -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(); } -- cgit v1.2.3-70-g09d2