From a290294c25efad4865bfbb2338c8a801c7de7be6 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 29 Mar 2020 00:55:57 +0100 Subject: [PATCH] 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. --- quickgui/controller.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/quickgui/controller.cpp b/quickgui/controller.cpp index adb3138..4d9ff55 100644 --- a/quickgui/controller.cpp +++ b/quickgui/controller.cpp @@ -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")); + } } }