Skip to content
Snippets Groups Projects
Commit a4dfd6c8 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by Nicolas Jager
Browse files

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
Branches
Tags
No related merge requests found
...@@ -254,10 +254,10 @@ void ProfileModelPrivate::slotAccountRemoved(Account* a) ...@@ -254,10 +254,10 @@ void ProfileModelPrivate::slotAccountRemoved(Account* a)
const int accIdx = n->m_Index; const int accIdx = n->m_Index;
q_ptr->beginRemoveRows(profIdx, accIdx, accIdx); q_ptr->beginRemoveRows(profIdx, accIdx, accIdx);
n->parent->children.removeAt(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++) for (int i = accIdx; i < n->parent->children.size(); i++)
n->parent->children[i]->m_Index--; n->parent->children[i]->m_Index--;
n->parent->m_uContent.m_pProfile->save(); n->parent->m_uContent.m_pProfile->save();
n->parent->m_uContent.m_pProfile->removeAccount(n->m_uContent.m_pAccount);
delete n; delete n;
q_ptr->endRemoveRows(); q_ptr->endRemoveRows();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment