diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index b497420b65..2d179192ef 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -1941,8 +1941,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 @@ -1951,6 +1951,8 @@ bool DatabaseWidget::lock() return false; } + m_attemptingLock = true; + emit databaseLockRequested(); // Force close any modal widgets associated with this widget @@ -1975,6 +1977,7 @@ bool DatabaseWidget::lock() MessageBox::Discard | MessageBox::Cancel, MessageBox::Cancel); if (result == MessageBox::Cancel) { + m_attemptingLock = false; return false; } } @@ -2001,9 +2004,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; } } @@ -2035,6 +2040,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 6622394e1a..aa00fc0abb 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -320,6 +320,7 @@ private slots: QUuid m_entryBeforeLock; int m_saveAttempts; + bool m_attemptingLock = false; QScopedPointer m_remoteSettings;