From d954519e102f157f32d4341b94260a97d6a759c7 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Sun, 12 Jun 2022 16:35:42 -0400 Subject: [PATCH] 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. --- src/gui/DatabaseOpenWidget.cpp | 7 +++++++ src/gui/DatabaseOpenWidget.h | 2 ++ src/gui/DatabaseWidget.cpp | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index d5c9707f8..4d313dd35 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -35,6 +35,7 @@ #endif #include +#include #include #include @@ -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() diff --git a/src/gui/DatabaseOpenWidget.h b/src/gui/DatabaseOpenWidget.h index 8a26b3045..8fca73c4e 100644 --- a/src/gui/DatabaseOpenWidget.h +++ b/src/gui/DatabaseOpenWidget.h @@ -46,6 +46,7 @@ public: void enterKey(const QString& pw, const QString& keyFile); QSharedPointer 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) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index fa791b538..b6e6b3749 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -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(); }