Fix crash when trying to close database during unlock

* Fix #7239 - prevent closing the database widget if the open dialog is still unlocking the database. This problem became slightly worse with quick unlock.

With this fix, if the user tries to close the database during unlock we will just ignore that request.
This commit is contained in:
Jonathan White 2022-06-12 16:35:42 -04:00
parent f0a7c636a4
commit d954519e10
3 changed files with 11 additions and 2 deletions

View File

@ -35,6 +35,7 @@
#endif
#include <QCheckBox>
#include <QCloseEvent>
#include <QDesktopServices>
#include <QFont>
@ -168,6 +169,11 @@ void DatabaseOpenWidget::hideEvent(QHideEvent* event)
}
}
bool DatabaseOpenWidget::unlockingDatabase()
{
return m_unlockingDatabase;
}
void DatabaseOpenWidget::load(const QString& filename)
{
clearForms();
@ -522,6 +528,7 @@ void DatabaseOpenWidget::setUserInteractionLock(bool state)
}
m_ui->centralStack->setEnabled(true);
}
m_unlockingDatabase = state;
}
bool DatabaseOpenWidget::isOnQuickUnlockScreen()

View File

@ -46,6 +46,7 @@ public:
void enterKey(const QString& pw, const QString& keyFile);
QSharedPointer<Database> database();
void resetQuickUnlock();
bool unlockingDatabase();
signals:
void dialogFinished(bool accepted);
@ -78,6 +79,7 @@ private slots:
private:
bool m_pollingHardwareKey = false;
bool m_blockQuickUnlock = false;
bool m_unlockingDatabase = false;
QTimer m_hideTimer;
Q_DISABLE_COPY(DatabaseOpenWidget)

View File

@ -1565,12 +1565,12 @@ Group* DatabaseWidget::currentGroup() const
void DatabaseWidget::closeEvent(QCloseEvent* event)
{
if (!isLocked() && !lock()) {
if (!lock() || m_databaseOpenWidget->unlockingDatabase()) {
event->ignore();
return;
}
m_databaseOpenWidget->resetQuickUnlock();
m_databaseOpenWidget->resetQuickUnlock();
event->accept();
}