summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/locationinformation.cpp12
-rw-r--r--desktop-widgets/locationinformation.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index a210ddf44..37bced819 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -36,6 +36,7 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo
ui.diveSiteCoordinates->installEventFilter(this);
connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &LocationInformationWidget::diveSiteChanged);
+ connect(&diveListNotifier, &DiveListNotifier::diveSiteDeleted, this, &LocationInformationWidget::diveSiteDeleted);
connect(qPrefUnits::instance(), &qPrefUnits::unit_systemChanged, this, &LocationInformationWidget::unitsChanged);
unitsChanged();
@@ -178,8 +179,19 @@ static location_t parseGpsText(const QString &text)
return { {0}, {0} };
}
+void LocationInformationWidget::diveSiteDeleted(struct dive_site *ds, int)
+{
+ // If the currently edited dive site was removed under our feet, close the widget.
+ // This will reset the dangling pointer.
+ if (ds && ds == diveSite)
+ acceptChanges();
+}
+
void LocationInformationWidget::acceptChanges()
{
+ diveSite = nullptr;
+ closeDistance = 0;
+
MainWindow::instance()->diveList->setEnabled(true);
MainWindow::instance()->setEnabledToolbar(true);
MainWindow::instance()->setApplicationState(ApplicationState::Default);
diff --git a/desktop-widgets/locationinformation.h b/desktop-widgets/locationinformation.h
index b6122d2fe..0e53a4439 100644
--- a/desktop-widgets/locationinformation.h
+++ b/desktop-widgets/locationinformation.h
@@ -34,6 +34,7 @@ public slots:
private slots:
void updateLabels();
void diveSiteChanged(struct dive_site *ds, int field);
+ void diveSiteDeleted(struct dive_site *ds, int);
void unitsChanged();
private:
void keyPressEvent(QKeyEvent *e) override;