Skip to content

Commit

Permalink
Fix crash when trying to close database during unlock
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
droidmonkey committed Jun 14, 2022
1 parent 6cb6f1f commit b86c3e6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/gui/DatabaseOpenWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#endif

#include <QCheckBox>
#include <QCloseEvent>
#include <QDesktopServices>
#include <QFont>

Expand Down Expand Up @@ -168,6 +169,11 @@ void DatabaseOpenWidget::hideEvent(QHideEvent* event)
}
}

bool DatabaseOpenWidget::unlockingDatabase()
{
return m_unlockingDatabase;
}

void DatabaseOpenWidget::load(const QString& filename)
{
clearForms();
Expand Down Expand Up @@ -522,6 +528,7 @@ void DatabaseOpenWidget::setUserInteractionLock(bool state)
}
m_ui->centralStack->setEnabled(true);
}
m_unlockingDatabase = state;
}

bool DatabaseOpenWidget::isOnQuickUnlockScreen()
Expand Down
2 changes: 2 additions & 0 deletions src/gui/DatabaseOpenWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class DatabaseOpenWidget : public DialogyWidget
void enterKey(const QString& pw, const QString& keyFile);
QSharedPointer<Database> database();
void resetQuickUnlock();
bool unlockingDatabase();

signals:
void dialogFinished(bool accepted);
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit b86c3e6

Please sign in to comment.