mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
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.
This commit is contained in:
parent
c1a66a8be9
commit
e0ea89e1cb
@ -1941,8 +1941,8 @@ bool DatabaseWidget::focusNextPrevChild(bool next)
|
|||||||
|
|
||||||
bool DatabaseWidget::lock()
|
bool DatabaseWidget::lock()
|
||||||
{
|
{
|
||||||
if (isLocked()) {
|
if (isLocked() || m_attemptingLock) {
|
||||||
return true;
|
return isLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't try to lock the database while saving, this will cause a deadlock
|
// Don't try to lock the database while saving, this will cause a deadlock
|
||||||
@ -1951,6 +1951,8 @@ bool DatabaseWidget::lock()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_attemptingLock = true;
|
||||||
|
|
||||||
emit databaseLockRequested();
|
emit databaseLockRequested();
|
||||||
|
|
||||||
// Force close any modal widgets associated with this widget
|
// Force close any modal widgets associated with this widget
|
||||||
@ -1975,6 +1977,7 @@ bool DatabaseWidget::lock()
|
|||||||
MessageBox::Discard | MessageBox::Cancel,
|
MessageBox::Discard | MessageBox::Cancel,
|
||||||
MessageBox::Cancel);
|
MessageBox::Cancel);
|
||||||
if (result == MessageBox::Cancel) {
|
if (result == MessageBox::Cancel) {
|
||||||
|
m_attemptingLock = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2001,9 +2004,11 @@ bool DatabaseWidget::lock()
|
|||||||
MessageBox::Save);
|
MessageBox::Save);
|
||||||
if (result == MessageBox::Save) {
|
if (result == MessageBox::Save) {
|
||||||
if (!save()) {
|
if (!save()) {
|
||||||
|
m_attemptingLock = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (result == MessageBox::Cancel) {
|
} else if (result == MessageBox::Cancel) {
|
||||||
|
m_attemptingLock = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2035,6 +2040,7 @@ bool DatabaseWidget::lock()
|
|||||||
auto newDb = QSharedPointer<Database>::create(m_db->filePath());
|
auto newDb = QSharedPointer<Database>::create(m_db->filePath());
|
||||||
replaceDatabase(newDb);
|
replaceDatabase(newDb);
|
||||||
|
|
||||||
|
m_attemptingLock = false;
|
||||||
emit databaseLocked();
|
emit databaseLocked();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -320,6 +320,7 @@ private:
|
|||||||
QUuid m_entryBeforeLock;
|
QUuid m_entryBeforeLock;
|
||||||
|
|
||||||
int m_saveAttempts;
|
int m_saveAttempts;
|
||||||
|
bool m_attemptingLock = false;
|
||||||
|
|
||||||
QScopedPointer<RemoteSettings> m_remoteSettings;
|
QScopedPointer<RemoteSettings> m_remoteSettings;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user