diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2018-05-31 12:00:11 +0300 |
---|---|---|
committer | Olivier Goffart <ogoffart@woboq.com> | 2018-06-04 11:32:30 +0300 |
commit | 76bb76a59e6633b9a38c7a0e36d8e51efc7a4047 (patch) | |
tree | 93d6c0cc05e1d99d907aa414ba5172c236428b2a /src/gui/folderstatusmodel.cpp | |
parent | 888f2aae2f31cb16ca8aa370ff44222d618bc146 (diff) |
FolderStatusModel: Fix crash when there is an error while expanding folders
In FolderStatusModel::slotLscolFinishedWithError, the call to parentInfo->resetSubs
deleted the 'job' and the reply 'r' which we accessed later to get the error code.
Fix this problem twice by
1) Get the error code before caling resetSubs
2) in FolderStatusModel::SubFolderInfo::resetSubs, call deleteLater instead of delete
Regression introduced in commit d69936e0
Issue #6562
Diffstat (limited to 'src/gui/folderstatusmodel.cpp')
-rw-r--r-- | src/gui/folderstatusmodel.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index 2e784101b..2109435ad 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -740,10 +740,11 @@ void FolderStatusModel::slotLscolFinishedWithError(QNetworkReply *r) if (parentInfo) { qCDebug(lcFolderStatus) << r->errorString(); parentInfo->_lastErrorString = r->errorString(); + auto error = r->error(); parentInfo->resetSubs(this, idx); - if (r->error() == QNetworkReply::ContentNotFoundError) { + if (error == QNetworkReply::ContentNotFoundError) { parentInfo->_fetched = true; } else { ASSERT(!parentInfo->hasLabel()); @@ -1226,7 +1227,11 @@ bool FolderStatusModel::SubFolderInfo::hasLabel() const void FolderStatusModel::SubFolderInfo::resetSubs(FolderStatusModel *model, QModelIndex index) { _fetched = false; - delete _fetchingJob; + if (_fetchingJob) { + disconnect(_fetchingJob, nullptr, model, nullptr); + _fetchingJob->deleteLater(); + _fetchingJob.clear(); + } if (hasLabel()) { model->beginRemoveRows(index, 0, 0); _fetchingLabel = false; |