From 81ea47a498b04e5f057e9d009fb73d9d559b37b5 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 28 Oct 2019 06:57:54 +0100 Subject: 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 Signed-off-by: Berthold Stoeger --- desktop-widgets/locationinformation.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'desktop-widgets') 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) -- cgit v1.2.3-70-g09d2