Fix opening files from command line

* Fix #2877 - password is unchecked by default
* Smarter activation of key components based on contents of text entry fields
* Prevent multiple copies of the same database from opening when the canonicalFileName != fileName
This commit is contained in:
Jonathan White 2019-03-26 22:23:16 -04:00
parent 52d411f423
commit edef225eab
No known key found for this signature in database
GPG key ID: 440FC65F2E0C6E01
4 changed files with 35 additions and 19 deletions

View file

@ -157,10 +157,8 @@ 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()->filePath() == canonicalFilePath) {
if (!password.isEmpty()) {
dbWidget->performUnlockDatabase(password, keyfile);
}
if (dbWidget && dbWidget->database()->canonicalFilePath() == canonicalFilePath) {
dbWidget->performUnlockDatabase(password, keyfile);
if (!inBackground) {
// switch to existing tab if file is already open
setCurrentIndex(indexOf(dbWidget));
@ -171,9 +169,7 @@ void DatabaseTabWidget::addDatabaseTab(const QString& filePath,
auto* dbWidget = new DatabaseWidget(QSharedPointer<Database>::create(filePath), this);
addDatabaseTab(dbWidget, inBackground);
if (!password.isEmpty()) {
dbWidget->performUnlockDatabase(password, keyfile);
}
dbWidget->performUnlockDatabase(password, keyfile);
updateLastDatabases(filePath);
}