1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Fix crash when KWallet is not available.

Summary:
Bug 398767
Currently, when the user clicks //remember password// when KWallet is disabled, **falkon** gets crashed.
This patch fixes the crash by checking if `KWallet` object is created and only then it adds to the folder.
The following functions are fixed:

  - addEntry

  - Update Entry

  - updateLastUsed

  - removeEntry

  - removeAll

Reviewers: SGOrava, drosca

Reviewed By: SGOrava, drosca

Subscribers: drosca, falkon

Tags: #falkon

Differential Revision: https://phabricator.kde.org/D26872
This commit is contained in:
Puneeth Chanda 2020-01-24 14:10:03 +01:00 committed by Juraj Oravec
parent 90664879c5
commit 1cecd14fd0

View File

@ -82,6 +82,10 @@ void KWalletPasswordBackend::addEntry(const PasswordEntry &entry)
{
initialize();
if (!m_wallet) {
return;
}
PasswordEntry stored = entry;
stored.id = QString("%1/%2").arg(entry.host, entry.username);
stored.updated = QDateTime::currentDateTime().toTime_t();
@ -94,6 +98,10 @@ bool KWalletPasswordBackend::updateEntry(const PasswordEntry &entry)
{
initialize();
if (!m_wallet) {
return false;
}
m_wallet->removeEntry(entry.id.toString());
m_wallet->writeEntry(entry.id.toString(), encodeEntry(entry));
@ -110,6 +118,10 @@ void KWalletPasswordBackend::updateLastUsed(PasswordEntry &entry)
{
initialize();
if (!m_wallet) {
return;
}
m_wallet->removeEntry(entry.id.toString());
entry.updated = QDateTime::currentDateTime().toTime_t();
@ -127,6 +139,10 @@ void KWalletPasswordBackend::removeEntry(const PasswordEntry &entry)
{
initialize();
if (!m_wallet) {
return;
}
m_wallet->removeEntry(entry.id.toString());
int index = m_allEntries.indexOf(entry);
@ -140,6 +156,10 @@ void KWalletPasswordBackend::removeAll()
{
initialize();
if (!m_wallet) {
return;
}
m_allEntries.clear();
m_wallet->removeFolder("Falkon");