summaryrefslogtreecommitdiffstats
path: root/qt-ui/simplewidgets.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-13 22:44:05 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-13 22:45:31 -0800
commitcd77e2e700da92fe0292320d5d4a82361104adfe (patch)
tree4f4a07ac444ee7578da52f8874c0a5917811bc7e /qt-ui/simplewidgets.cpp
parente32459d3139e5f9815550fe3ebbc6bfff96d5d97 (diff)
downloadsubsurface-cd77e2e700da92fe0292320d5d4a82361104adfe.tar.gz
Make sure there is a dive site if you try to edit it
If the user clicks on manage (or double clicks on the globe) and the displayed_dive doesn't actually have a dive site associated with it (e.g. because we are adding a dive or because it was imported or downloaded without dive site information, then we need to make sure that there is an empty dive site that we can make changes to. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/simplewidgets.cpp')
-rw-r--r--qt-ui/simplewidgets.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp
index 4f050063c..f32ce9b19 100644
--- a/qt-ui/simplewidgets.cpp
+++ b/qt-ui/simplewidgets.cpp
@@ -666,10 +666,16 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo
void LocationInformationWidget::setLocationId(uint32_t uuid)
{
currentDs = get_dive_site_by_uuid(uuid);
- if (currentDs)
- displayed_dive_site = *currentDs;
- else
- memset(&displayed_dive, 0, sizeof(displayed_dive));
+
+ if (!currentDs) {
+ currentDs = get_dive_site_by_uuid(create_dive_site(""));
+ displayed_dive.dive_site_uuid = currentDs->uuid;
+ ui.diveSiteName->clear();
+ ui.diveSiteDescription->clear();
+ ui.diveSiteNotes->clear();
+ ui.diveSiteCoordinates->clear();
+ }
+ displayed_dive_site = *currentDs;
ui.diveSiteName->setText(displayed_dive_site.name);
ui.diveSiteDescription->setText(displayed_dive_site.description);
ui.diveSiteNotes->setPlainText(displayed_dive_site.notes);
@@ -708,6 +714,7 @@ void LocationInformationWidget::acceptChanges()
void LocationInformationWidget::rejectChanges()
{
+ Q_ASSERT(currentDs != NULL);
setLocationId(currentDs->uuid);
emit informationManagementEnded();
}