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 on database open from browser #9939

Merged
merged 2 commits into from
Oct 24, 2023
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
2 changes: 1 addition & 1 deletion src/browser/BrowserService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ bool BrowserService::openDatabase(bool triggerUnlock)
return true;
}

if (triggerUnlock) {
if (triggerUnlock && !m_bringToFrontRequested) {
m_bringToFrontRequested = true;
updateWindowState();
emit requestUnlock();
Expand Down
9 changes: 8 additions & 1 deletion src/gui/DatabaseTabWidget.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 KeePassXC Team <[email protected]>
* Copyright (C) 2023 KeePassXC Team <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -41,6 +41,7 @@ DatabaseTabWidget::DatabaseTabWidget(QWidget* parent)
, m_dbWidgetStateSync(new DatabaseWidgetStateSync(this))
, m_dbWidgetPendingLock(nullptr)
, m_databaseOpenDialog(new DatabaseOpenDialog(this))
, m_databaseOpenInProgress(false)
{
auto* tabBar = new QTabBar(this);
tabBar->setAcceptDrops(true);
Expand Down Expand Up @@ -857,6 +858,7 @@ void DatabaseTabWidget::emitDatabaseLockChanged()
emit databaseLocked(dbWidget);
} else {
emit databaseUnlocked(dbWidget);
m_databaseOpenInProgress = false;
}
}

Expand Down Expand Up @@ -889,6 +891,11 @@ void DatabaseTabWidget::performGlobalAutoType(const QString& search)

void DatabaseTabWidget::performBrowserUnlock()
{
if (m_databaseOpenInProgress) {
return;
}

m_databaseOpenInProgress = true;
auto dbWidget = currentDatabaseWidget();
if (dbWidget && dbWidget->isLocked()) {
unlockAnyDatabaseInDialog(DatabaseOpenDialog::Intent::Browser);
Expand Down
3 changes: 2 additions & 1 deletion src/gui/DatabaseTabWidget.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 KeePassXC Team <[email protected]>
* Copyright (C) 2023 KeePassXC Team <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -117,6 +117,7 @@ private slots:
QPointer<DatabaseWidget> m_dbWidgetPendingLock;
QPointer<DatabaseOpenDialog> m_databaseOpenDialog;
QTimer m_lockDelayTimer;
bool m_databaseOpenInProgress;
};

#endif // KEEPASSX_DATABASETABWIDGET_H