From eab31b69ee712580c2e3a26c76bc200707f6d258 Mon Sep 17 00:00:00 2001 From: Manuel Date: Fri, 19 Oct 2018 22:04:08 +0200 Subject: [PATCH] Unlock view status was lost after switching view or refresh (#1565) This solves these two problems that seem to have being introduced in d5a049062d4795ba91b860ac33561450ba1dce8c - The unlocked-view status was not applied again when switching back to the view (you cannot edit and the Delete Record button is not reenabled) or after refreshing. - The 'Unlock view editing' check state persisted when switching between views. See issue #141. --- src/MainWindow.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index f6cd0cea..6e77911b 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -3182,11 +3182,6 @@ void MainWindow::unlockViewEditing(bool unlock, QString pk) return; } - // If the settings didn't change, do nothing. This avoids an infinite loop - BrowseDataTableSettings& settings = browseTableSettings[currentTable]; - if(unlock != settings.unlockViewPk.isEmpty() && settings.unlockViewPk == pk) - return; - sqlb::ViewPtr obj = db.getObjectByName(currentTable); // If the view gets unlocked for editing and we don't have a 'primary key' for this view yet, then ask for one @@ -3230,11 +3225,16 @@ void MainWindow::unlockViewEditing(bool unlock, QString pk) ui->actionUnlockViewEditing->setChecked(unlock); ui->actionUnlockViewEditing->blockSignals(false); - // Save settings for this table - settings.unlockViewPk = pk; + // If the settings didn't change, do not try to reapply them. + // This avoids an infinite mutual recursion. + BrowseDataTableSettings& settings = browseTableSettings[currentTable]; - // Reapply the view settings. This seems to be necessary as a workaround for newer Qt versions. - applyBrowseTableSettings(settings); + if(settings.unlockViewPk != pk) { + // Save settings for this table + settings.unlockViewPk = pk; + // Reapply the view settings. This seems to be necessary as a workaround for newer Qt versions. + applyBrowseTableSettings(settings); + } } sqlb::ObjectIdentifier MainWindow::currentlyBrowsedTableName() const