Don't abort propagation job abortions synchronously from finished

This leads to crashes since we changed the connection to the parent
jobs not to be queued anymore.
We don't really need to bubble up the finished state through
parents in that case, and it would also mean that we'd recurse
all the way through leaves as we go up to each parent. So just call
abort directly on the OwncloudPropagator and make sure the abortion
call is posted to the event loop.
This commit is contained in:
Jocelyn Turcotte 2017-02-17 12:57:24 +01:00
parent 19bf5e2ff1
commit 793a994ce6
2 changed files with 12 additions and 8 deletions

View file

@ -171,6 +171,11 @@ void PropagateItemJob::done(SyncFileItem::Status status, const QString &errorStr
emit propagator()->itemCompleted(_item);
emit finished(status);
if (status == SyncFileItem::FatalError) {
// Abort all remaining jobs.
propagator()->abort();
}
}
/**
@ -669,12 +674,9 @@ void PropagatorCompositeJob::slotSubJobFinished(SyncFileItem::Status status)
ASSERT(i >= 0);
_runningJobs.remove(i);
if (status == SyncFileItem::FatalError) {
abort();
_state = Finished;
emit finished(status);
return;
} else if (status == SyncFileItem::NormalError || status == SyncFileItem::SoftError) {
if (status == SyncFileItem::FatalError
|| status == SyncFileItem::NormalError
|| status == SyncFileItem::SoftError) {
_hasError = status;
}

View file

@ -331,9 +331,11 @@ public:
void abort() {
_abortRequested.fetchAndStoreOrdered(true);
if (_rootJob) {
_rootJob->abort();
// We're possibly already in an item's finished stack
QMetaObject::invokeMethod(_rootJob.data(), "abort", Qt::QueuedConnection);
}
emitFinished(SyncFileItem::NormalError);
// abort() of all jobs will likely have already resulted in finished being emitted, but just in case.
QMetaObject::invokeMethod(this, "emitFinished", Qt::QueuedConnection, Q_ARG(SyncFileItem::Status, SyncFileItem::NormalError));
}
// timeout in seconds