1
0
Fork 0
mirror of https://github.com/subsurface/subsurface.git synced 2025-02-19 22:16:15 +00:00

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>
This commit is contained in:
Dirk Hohndel 2015-05-27 06:31:34 -07:00
parent c6783739c9
commit bfee0a13f0

View file

@ -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;