Skip to content

Commit 0941ff4

Browse files
committed
Prevent multiple lock requests on Linux
* Fixes #11000 When the screen locks on e.g. gnome we receive multiple independent signals of that, namely the Gnome session manager and the gnome / freedesktop screensaver. When this happens, this causes multiple "lock database" requests to be issued. The first one correctly shows the question to discard/cancel, but the second one while the first is still asking goes and dismisses the question and then goes to ask it again. The result is it acts like you didn't answer correctly (ie, to cancel) and the database is locked.
1 parent 12ee4a9 commit 0941ff4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/gui/DatabaseWidget.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -1953,8 +1953,8 @@ bool DatabaseWidget::focusNextPrevChild(bool next)
19531953

19541954
bool DatabaseWidget::lock()
19551955
{
1956-
if (isLocked()) {
1957-
return true;
1956+
if (isLocked() || m_attemptingLock) {
1957+
return isLocked();
19581958
}
19591959

19601960
// Don't try to lock the database while saving, this will cause a deadlock
@@ -1963,6 +1963,8 @@ bool DatabaseWidget::lock()
19631963
return false;
19641964
}
19651965

1966+
m_attemptingLock = true;
1967+
19661968
emit databaseLockRequested();
19671969

19681970
// Force close any modal widgets associated with this widget
@@ -1987,6 +1989,7 @@ bool DatabaseWidget::lock()
19871989
MessageBox::Discard | MessageBox::Cancel,
19881990
MessageBox::Cancel);
19891991
if (result == MessageBox::Cancel) {
1992+
m_attemptingLock = false;
19901993
return false;
19911994
}
19921995
}
@@ -2013,9 +2016,11 @@ bool DatabaseWidget::lock()
20132016
MessageBox::Save);
20142017
if (result == MessageBox::Save) {
20152018
if (!save()) {
2019+
m_attemptingLock = false;
20162020
return false;
20172021
}
20182022
} else if (result == MessageBox::Cancel) {
2023+
m_attemptingLock = false;
20192024
return false;
20202025
}
20212026
}
@@ -2047,6 +2052,7 @@ bool DatabaseWidget::lock()
20472052
auto newDb = QSharedPointer<Database>::create(m_db->filePath());
20482053
replaceDatabase(newDb);
20492054

2055+
m_attemptingLock = false;
20502056
emit databaseLocked();
20512057

20522058
return true;

src/gui/DatabaseWidget.h

+1
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ private slots:
323323
QUuid m_entryBeforeLock;
324324

325325
int m_saveAttempts;
326+
bool m_attemptingLock = false;
326327

327328
QScopedPointer<RemoteSettings> m_remoteSettings;
328329

0 commit comments

Comments
 (0)