diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 68b0fdcc2b..8ec29b9513 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -1953,8 +1953,8 @@ bool DatabaseWidget::focusNextPrevChild(bool next) bool DatabaseWidget::lock() { - if (isLocked()) { - return true; + if (isLocked() || m_attemptingLock) { + return isLocked(); } // Don't try to lock the database while saving, this will cause a deadlock @@ -1963,6 +1963,8 @@ bool DatabaseWidget::lock() return false; } + m_attemptingLock = true; + emit databaseLockRequested(); // Force close any modal widgets associated with this widget @@ -1987,6 +1989,7 @@ bool DatabaseWidget::lock() MessageBox::Discard | MessageBox::Cancel, MessageBox::Cancel); if (result == MessageBox::Cancel) { + m_attemptingLock = false; return false; } } @@ -2013,9 +2016,11 @@ bool DatabaseWidget::lock() MessageBox::Save); if (result == MessageBox::Save) { if (!save()) { + m_attemptingLock = false; return false; } } else if (result == MessageBox::Cancel) { + m_attemptingLock = false; return false; } } @@ -2047,6 +2052,7 @@ bool DatabaseWidget::lock() auto newDb = QSharedPointer::create(m_db->filePath()); replaceDatabase(newDb); + m_attemptingLock = false; emit databaseLocked(); return true; diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index b66589d7e8..4c13f2a900 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -323,6 +323,7 @@ private slots: QUuid m_entryBeforeLock; int m_saveAttempts; + bool m_attemptingLock = false; QScopedPointer m_remoteSettings;