Commit a4dfd6c8 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by Nicolas Jager

fix crash when last account is destroyed

When deleting the last account, method ProfileModelPrivate::slotAccountRemoved
destroy the account then save the profile.
This last triggers NewAccountModelPimpl::slotProfileUpdated().
But this one access to an empty account array (as all account are destroyed).

Re-order profile-save/account delete to solve the issue (save first, destroy after).

Change-Id: I427a51c3d1f97d0127567531616f360df45e4652
Reviewed-by: default avatarNicolas Jäger <nicolas.jager@savoirfairelinux.com>
parent e9924324
......@@ -254,10 +254,10 @@ void ProfileModelPrivate::slotAccountRemoved(Account* a)
const int accIdx = n->m_Index;
q_ptr->beginRemoveRows(profIdx, accIdx, accIdx);
n->parent->children.removeAt(accIdx);
n->parent->m_uContent.m_pProfile->removeAccount(n->m_uContent.m_pAccount);
for (int i = accIdx; i < n->parent->children.size(); i++)
n->parent->children[i]->m_Index--;
n->parent->m_uContent.m_pProfile->save();
n->parent->m_uContent.m_pProfile->removeAccount(n->m_uContent.m_pAccount);
delete n;
q_ptr->endRemoveRows();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment