From bfee0a13f053829a34907eb0d27e5abe681f0e50 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 27 May 2015 06:31:34 -0700 Subject: 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 --- qt-ui/locationinformation.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'qt-ui') 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; -- cgit v1.2.3-70-g09d2