aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-27 06:31:34 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-27 06:31:34 -0700
commitbfee0a13f053829a34907eb0d27e5abe681f0e50 (patch)
treef309a7aadc921ea132b0c5f264a974e78b35e74f
parentc6783739c909991b30e95c8fd16dc5bc8ca4a409 (diff)
downloadsubsurface-bfee0a13f053829a34907eb0d27e5abe681f0e50.tar.gz
Dive site management: make sure currentDs is valid
When double clicking on the globe on a dive with no dive site we did almost the right thing - except that we didn't create a dive site. Not 100% sure this is the right place to do this, but it seems to work and prevents the crash. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/locationinformation.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp
index 6e996954b..b96d4e46d 100644
--- a/qt-ui/locationinformation.cpp
+++ b/qt-ui/locationinformation.cpp
@@ -219,13 +219,17 @@ void LocationInformationWidget::enableEdition()
ui.diveSiteMessage->addAction(acceptAction);
ui.diveSiteMessage->addAction(rejectAction);
ui.diveSiteMessage->setCloseButtonVisible(false);
+ if (!currentDs) {
+ displayed_dive.dive_site_uuid = create_dive_site(NULL);
+ currentDs = get_dive_site_by_uuid(displayed_dive.dive_site_uuid);
+ }
}
extern bool parseGpsText(const QString &gps_text, double *latitude, double *longitude);
void LocationInformationWidget::on_diveSiteCoordinates_textChanged(const QString& text)
{
- if (!same_string(qPrintable(text), printGPSCoords(currentDs->latitude.udeg, currentDs->longitude.udeg))) {
+ if (!currentDs || !same_string(qPrintable(text), printGPSCoords(currentDs->latitude.udeg, currentDs->longitude.udeg))) {
double latitude, longitude;
if (parseGpsText(text, &latitude, &longitude)) {
displayed_dive_site.latitude.udeg = latitude * 1000000;