From 0d21936e9576a3a0e8e7ba882cb9f152be9afb38 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 31 May 2018 11:00:11 +0200 Subject: [PATCH] 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 --- src/gui/folderstatusmodel.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/folderstatusmodel.cpp b/src/gui/folderstatusmodel.cpp index e9f6974c8..3db8eda89 100644 --- a/src/gui/folderstatusmodel.cpp +++ b/src/gui/folderstatusmodel.cpp @@ -760,10 +760,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()); @@ -1241,7 +1242,11 @@ bool FolderStatusModel::SubFolderInfo::hasLabel() const void FolderStatusModel::SubFolderInfo::resetSubs(FolderStatusModel *model, QModelIndex index) { _fetched = false; - _fetchingJob->deleteLater(); + if (_fetchingJob) { + disconnect(_fetchingJob, nullptr, model, nullptr); + _fetchingJob->deleteLater(); + _fetchingJob.clear(); + } if (hasLabel()) { model->beginRemoveRows(index, 0, 0); _fetchingLabel = false; -- 2.39.5