Show password prompt in any error case in Qt Quick GUI

It might happen that an empty/incorrect password does not lead to
a crypto error. Then the data is nevertheless wrongly decrypted and
trying again with the correct password might help.

Not using PasswordFile::isEncryptionUsed() here like in the Qt Widgets
GUI for better/easier integration with Android's storage access
framework.
This commit is contained in:
Martchus 2020-03-29 00:55:57 +01:00
parent 9ff25a27b7
commit a290294c25
1 changed files with 7 additions and 1 deletions

View File

@ -143,7 +143,13 @@ void Controller::load()
emit fileError(tr("A crypto error occured when opening the file: ") + QString::fromLocal8Bit(e.what()), QStringLiteral("load"));
}
} catch (...) {
emitFileError(tr("loading"));
if ((m_file.saveOptions() & PasswordFileSaveFlags::Encryption) && m_password.isEmpty()) {
emit passwordRequired(m_filePath);
} else {
// clear password since the password which has been provided might not have been correct (although there was no CryptoException)
clearPassword();
emitFileError(tr("loading"));
}
}
}