From: Olivier Goffart Date: Thu, 31 May 2018 09:00:11 +0000 (+0200) Subject: FolderStatusModel: Fix crash when there is an error while expanding folders X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~574 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0d21936e9576a3a0e8e7ba882cb9f152be9afb38;p=nextcloud-desktop.git 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 --- 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;