From c24a8ba20823fccaed05a93e2a95d12732dd3c10 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 1 Dec 2015 19:21:52 +0100 Subject: [PATCH] Account removal: More crash fixes for Windows Seems things happen a bit different here, maybe because of paint events. For #4229 #4202 --- src/gui/accountsettings.cpp | 1 + src/gui/folderstatusmodel.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index ff63691e2..836a15611 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -689,6 +689,7 @@ void AccountSettings::slotDeleteAccount() } } + _model->setAccountState(0); // Else it might access during destruction. This should be better handled by it having a QSharedPointer auto manager = AccountManager::instance(); manager->deleteAccount(_accountState); manager->save(); diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 14d0bf190..86be5e902 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -53,6 +53,8 @@ void FolderStatusModel::setAccountState(const AccountState* accountState) auto folders = FolderMan::instance()->map(); foreach (auto f, folders) { + if (!accountState) + break; if (f->accountState() != accountState) continue; SubFolderInfo info; @@ -74,6 +76,9 @@ void FolderStatusModel::setAccountState(const AccountState* accountState) Qt::ItemFlags FolderStatusModel::flags ( const QModelIndex &index ) const { + if (!_accountState) { + return 0; + } switch (classify(index)) { case AddButton: { Qt::ItemFlags ret; @@ -479,6 +484,9 @@ bool FolderStatusModel::hasChildren(const QModelIndex& parent) const bool FolderStatusModel::canFetchMore(const QModelIndex& parent) const { + if (!_accountState) { + return false; + } if (_accountState->state() != AccountState::Connected) { return false; } -- 2.30.2