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
|
#define QUINT32_MAX 4294967295U
|
||||||
#endif
|
#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
|
template <typename T> struct AddConst
|
||||||
{
|
{
|
||||||
typedef const T Type;
|
typedef const T Type;
|
||||||
|
@ -156,6 +156,7 @@ void DatabaseTabWidget::addDatabaseTab(const QString& filePath,
|
|||||||
{
|
{
|
||||||
QFileInfo fileInfo(filePath);
|
QFileInfo fileInfo(filePath);
|
||||||
QString canonicalFilePath = fileInfo.canonicalFilePath();
|
QString canonicalFilePath = fileInfo.canonicalFilePath();
|
||||||
|
|
||||||
if (canonicalFilePath.isEmpty()) {
|
if (canonicalFilePath.isEmpty()) {
|
||||||
emit messageGlobal(tr("Failed to open %1. It either does not exist or is not accessible.").arg(filePath),
|
emit messageGlobal(tr("Failed to open %1. It either does not exist or is not accessible.").arg(filePath),
|
||||||
MessageWidget::Error);
|
MessageWidget::Error);
|
||||||
@ -165,7 +166,7 @@ void DatabaseTabWidget::addDatabaseTab(const QString& filePath,
|
|||||||
for (int i = 0, c = count(); i < c; ++i) {
|
for (int i = 0, c = count(); i < c; ++i) {
|
||||||
auto* dbWidget = databaseWidgetFromIndex(i);
|
auto* dbWidget = databaseWidgetFromIndex(i);
|
||||||
Q_ASSERT(dbWidget);
|
Q_ASSERT(dbWidget);
|
||||||
if (dbWidget && dbWidget->database()->canonicalFilePath() == canonicalFilePath) {
|
if (dbWidget && dbWidget->database()->canonicalFilePath().compare(canonicalFilePath, FILE_CASE_SENSITIVE) == 0) {
|
||||||
dbWidget->performUnlockDatabase(password, keyfile);
|
dbWidget->performUnlockDatabase(password, keyfile);
|
||||||
if (!inBackground) {
|
if (!inBackground) {
|
||||||
// switch to existing tab if file is already open
|
// switch to existing tab if file is already open
|
||||||
|
@ -400,7 +400,6 @@ void DatabaseWidget::replaceDatabase(QSharedPointer<Database> db)
|
|||||||
m_db = std::move(db);
|
m_db = std::move(db);
|
||||||
connectDatabaseSignals();
|
connectDatabaseSignals();
|
||||||
m_groupView->changeDatabase(m_db);
|
m_groupView->changeDatabase(m_db);
|
||||||
processAutoOpen();
|
|
||||||
|
|
||||||
// Restore the new parent group pointer, if not found default to the root group
|
// 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
|
// this prevents data loss when merging a database while creating a new entry
|
||||||
@ -946,6 +945,7 @@ void DatabaseWidget::loadDatabase(bool accepted)
|
|||||||
if (accepted) {
|
if (accepted) {
|
||||||
replaceDatabase(openWidget->database());
|
replaceDatabase(openWidget->database());
|
||||||
switchToMainView();
|
switchToMainView();
|
||||||
|
processAutoOpen();
|
||||||
m_saveAttempts = 0;
|
m_saveAttempts = 0;
|
||||||
emit databaseUnlocked();
|
emit databaseUnlocked();
|
||||||
if (config()->get("MinimizeAfterUnlock").toBool()) {
|
if (config()->get("MinimizeAfterUnlock").toBool()) {
|
||||||
@ -1032,6 +1032,7 @@ void DatabaseWidget::unlockDatabase(bool accepted)
|
|||||||
m_entryBeforeLock = QUuid();
|
m_entryBeforeLock = QUuid();
|
||||||
|
|
||||||
switchToMainView();
|
switchToMainView();
|
||||||
|
processAutoOpen();
|
||||||
emit databaseUnlocked();
|
emit databaseUnlocked();
|
||||||
|
|
||||||
if (senderDialog && senderDialog->intent() == DatabaseOpenDialog::Intent::AutoType) {
|
if (senderDialog && senderDialog->intent() == DatabaseOpenDialog::Intent::AutoType) {
|
||||||
@ -1468,6 +1469,7 @@ void DatabaseWidget::reloadDatabaseFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
replaceDatabase(db);
|
replaceDatabase(db);
|
||||||
|
processAutoOpen();
|
||||||
restoreGroupEntryFocus(groupBeforeReload, entryBeforeReload);
|
restoreGroupEntryFocus(groupBeforeReload, entryBeforeReload);
|
||||||
m_blockAutoSave = false;
|
m_blockAutoSave = false;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user