mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Prevent recursive loads using AutoOpen
* Fix #3334 - AutoOpen is now processed after the database widget is put into view mode to prevent infinite recursion of unlock attempts if two databases auto open each other.
This commit is contained in:
parent
cb9929712c
commit
4edb623745
@ -36,6 +36,12 @@
|
||||
#define QUINT32_MAX 4294967295U
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_MACOS)
|
||||
#define FILE_CASE_SENSITIVE Qt::CaseInsensitive
|
||||
#else
|
||||
#define FILE_CASE_SENSITIVE Qt::CaseSensitive
|
||||
#endif
|
||||
|
||||
template <typename T> struct AddConst
|
||||
{
|
||||
typedef const T Type;
|
||||
|
@ -156,6 +156,7 @@ void DatabaseTabWidget::addDatabaseTab(const QString& filePath,
|
||||
{
|
||||
QFileInfo fileInfo(filePath);
|
||||
QString canonicalFilePath = fileInfo.canonicalFilePath();
|
||||
|
||||
if (canonicalFilePath.isEmpty()) {
|
||||
emit messageGlobal(tr("Failed to open %1. It either does not exist or is not accessible.").arg(filePath),
|
||||
MessageWidget::Error);
|
||||
@ -165,7 +166,7 @@ void DatabaseTabWidget::addDatabaseTab(const QString& filePath,
|
||||
for (int i = 0, c = count(); i < c; ++i) {
|
||||
auto* dbWidget = databaseWidgetFromIndex(i);
|
||||
Q_ASSERT(dbWidget);
|
||||
if (dbWidget && dbWidget->database()->canonicalFilePath() == canonicalFilePath) {
|
||||
if (dbWidget && dbWidget->database()->canonicalFilePath().compare(canonicalFilePath, FILE_CASE_SENSITIVE) == 0) {
|
||||
dbWidget->performUnlockDatabase(password, keyfile);
|
||||
if (!inBackground) {
|
||||
// switch to existing tab if file is already open
|
||||
|
@ -400,7 +400,6 @@ void DatabaseWidget::replaceDatabase(QSharedPointer<Database> db)
|
||||
m_db = std::move(db);
|
||||
connectDatabaseSignals();
|
||||
m_groupView->changeDatabase(m_db);
|
||||
processAutoOpen();
|
||||
|
||||
// Restore the new parent group pointer, if not found default to the root group
|
||||
// this prevents data loss when merging a database while creating a new entry
|
||||
@ -946,6 +945,7 @@ void DatabaseWidget::loadDatabase(bool accepted)
|
||||
if (accepted) {
|
||||
replaceDatabase(openWidget->database());
|
||||
switchToMainView();
|
||||
processAutoOpen();
|
||||
m_saveAttempts = 0;
|
||||
emit databaseUnlocked();
|
||||
if (config()->get("MinimizeAfterUnlock").toBool()) {
|
||||
@ -1032,6 +1032,7 @@ void DatabaseWidget::unlockDatabase(bool accepted)
|
||||
m_entryBeforeLock = QUuid();
|
||||
|
||||
switchToMainView();
|
||||
processAutoOpen();
|
||||
emit databaseUnlocked();
|
||||
|
||||
if (senderDialog && senderDialog->intent() == DatabaseOpenDialog::Intent::AutoType) {
|
||||
@ -1468,6 +1469,7 @@ void DatabaseWidget::reloadDatabaseFile()
|
||||
}
|
||||
|
||||
replaceDatabase(db);
|
||||
processAutoOpen();
|
||||
restoreGroupEntryFocus(groupBeforeReload, entryBeforeReload);
|
||||
m_blockAutoSave = false;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user