Skip to content
Snippets Groups Projects
Commit fe443f08 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by Adrien Béraud
Browse files

AccountModel: do proper sanity check in slotContactRemoved

pointers used without checking for nullptr value.

Change-Id: I63eb9b460b44264857ced9ae0aff9bbd634b241c
parent c956c7d2
No related branches found
No related tags found
No related merge requests found
......@@ -556,12 +556,17 @@ AccountModelPrivate::slotContactAdded(const QString &accountID, const QString &u
void
AccountModelPrivate::slotContactRemoved(const QString &accountID, const QString &uri, bool banned)
{
if (not banned)
return;
auto account = q_ptr->getById(accountID.toLatin1());
auto cm = PhoneDirectoryModel::instance().getNumber(uri, account);
account->bannedContactModel()->add(cm);
if (auto account = q_ptr->getById(accountID.toLatin1())) {
if (auto cm = PhoneDirectoryModel::instance().getNumber(uri, account)) {
auto& daemon_contacts = account->getContacts();
// TODO: removeAll() is 5.4 - not yet supported by debian 8
auto index = daemon_contacts.indexOf(cm);
if (index >= 0)
daemon_contacts.remove(index);
if (banned)
account->bannedContactModel()->add(cm);
}
}
}
///Update accounts
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment