Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent multiple lock requests on Linux #11306

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1951,6 +1951,8 @@ bool DatabaseWidget::lock()
return false;
}

m_attemptingLock = true;

emit databaseLockRequested();

// Force close any modal widgets associated with this widget
Expand All @@ -1975,6 +1977,7 @@ bool DatabaseWidget::lock()
MessageBox::Discard | MessageBox::Cancel,
MessageBox::Cancel);
if (result == MessageBox::Cancel) {
m_attemptingLock = false;
return false;
}
}
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -2035,6 +2040,7 @@ bool DatabaseWidget::lock()
auto newDb = QSharedPointer<Database>::create(m_db->filePath());
replaceDatabase(newDb);

m_attemptingLock = false;
emit databaseLocked();

return true;
Expand Down
1 change: 1 addition & 0 deletions src/gui/DatabaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ private slots:
QUuid m_entryBeforeLock;

int m_saveAttempts;
bool m_attemptingLock = false;

QScopedPointer<RemoteSettings> m_remoteSettings;

Expand Down