From: Olivier Goffart Date: Thu, 9 Mar 2017 08:41:36 +0000 (+0100) Subject: Propagator: Attempt to fix a crash in OwncloudPropagator::scheduleNextJob X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~790^2~17 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9c83c57f1cc0a69a85b54080315593843334df92;p=nextcloud-desktop.git Propagator: Attempt to fix a crash in OwncloudPropagator::scheduleNextJob The crash reporter shows many crashes in OwncloudPropagator::scheduleNextJob. We don't really know what could be the cause, but it's probably because the _activeJobList contains dangling pointer. So this patch makes sure to remove all the jobs from this list as they get destroyed. --- diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index e2c910213..af584b091 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -94,6 +94,16 @@ int OwncloudPropagator::hardMaximumActiveJob() return max; } +PropagateItemJob::~PropagateItemJob() +{ + if (auto p = propagator()) { + // Normally, every job should clean itself from the _activeJobList. So this should not be + // needed. But if a job has a bug or is deleted before the network jobs signal get received, + // we might risk end up with dangling pointer in the list which may cause crashes. + p->_activeJobList.removeAll(this); + } +} + /** Updates, creates or removes a blacklist entry for the given item. * * Returns whether the error should be suppressed. diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index ef5db3b1e..e16e2aee5 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -160,6 +160,7 @@ private: public: PropagateItemJob(OwncloudPropagator* propagator, const SyncFileItemPtr &item) : PropagatorJob(propagator), _item(item) {} + ~PropagateItemJob(); bool scheduleNextJob() Q_DECL_OVERRIDE { if (_state != NotYetStarted) {