Account removal: More crash fixes for Windows
authorMarkus Goetz <markus@woboq.com>
Tue, 1 Dec 2015 18:21:52 +0000 (19:21 +0100)
committerMarkus Goetz <markus@woboq.com>
Tue, 1 Dec 2015 18:21:52 +0000 (19:21 +0100)
Seems things happen a bit different here, maybe because of paint events.

For #4229 #4202

src/gui/accountsettings.cpp
src/gui/folderstatusmodel.cpp

index ff63691e270b2b5317b865cc7b79a2188626813c..836a156112051d09bd5d1b78e669d213f45393c5 100644 (file)
@@ -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();
index 14d0bf19040b50d33d6e19ee7ef47ef7243ca02f..86be5e90200f130dac9f4b0075ef77c71bc0199c 100644 (file)
@@ -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;
     }