Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when trying to close database during unlock #8144

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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