summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-10-28 06:57:54 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-28 04:40:26 -0700
commit81ea47a498b04e5f057e9d009fb73d9d559b37b5 (patch)
treed82c58d58628dde430414d4584676d66b69e7e2e
parenta9b1fbdcc5aba16cb5b5d3acdbbe2b4e48768e1c (diff)
downloadsubsurface-81ea47a498b04e5f057e9d009fb73d9d559b37b5.tar.gz
Desktop: fix dive site editing
When clicking "done" on the dive site edit screen, the diveSite member variable was reset to nullptr in acceptChanges() at the beginning of the function. This prevented posting an undo-command as a consequence of the active widget losing focus. Reset the diveSite variable after exiting dive-site mode, which causes the active widget to lose focus. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--CHANGELOG.md1
-rw-r--r--desktop-widgets/locationinformation.cpp8
2 files changed, 8 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 032d55791..be63cb75d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,4 @@
+Desktop: register changes when clicking "done" on dive-site edit screen
Mobile: re-enable GPS location service icon in global drawer
Mobile: add support for editing the dive number of a dive
Desktop: make dive replanning undoable
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index 3a0d2f442..4f1241d82 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -189,13 +189,19 @@ void LocationInformationWidget::diveSiteDeleted(struct dive_site *ds, int)
void LocationInformationWidget::acceptChanges()
{
- diveSite = nullptr;
closeDistance = 0;
MainWindow::instance()->diveList->setEnabled(true);
MainWindow::instance()->setEnabledToolbar(true);
MainWindow::instance()->setApplicationState(ApplicationState::Default);
MultiFilterSortModel::instance()->stopFilterDiveSites();
+
+ // Subtlety alert: diveSite must be cleared *after* exiting the dive-site mode.
+ // Exiting dive-site mode removes the focus from the active widget and
+ // thus fires the corresponding editingFinished signal, which in turn creates
+ // an undo-command. To set an undo-command, the widget has to know the
+ // currently edited dive-site.
+ diveSite = nullptr;
}
void LocationInformationWidget::initFields(dive_site *ds)