From 7c1871ae652fdd73d274fb0bef3fad787d39385d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 22 Nov 2018 08:46:33 +0100 Subject: [PATCH] Account: Fix crash when deleting an account We should not have request parented to the account, otherwise we might get a loop on the deletion order. Issue #6893 --- src/libsync/abstractnetworkjob.cpp | 3 +++ src/libsync/account.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libsync/abstractnetworkjob.cpp b/src/libsync/abstractnetworkjob.cpp index 7365c97a3..e44af32a7 100644 --- a/src/libsync/abstractnetworkjob.cpp +++ b/src/libsync/abstractnetworkjob.cpp @@ -54,6 +54,9 @@ AbstractNetworkJob::AbstractNetworkJob(AccountPtr account, const QString &path, , _reply(nullptr) , _path(path) { + // Since we hold a QSharedPointer to the account, this makes no sense. (issue #6893) + ASSERT(account != parent); + _timer.setSingleShot(true); _timer.setInterval((httpTimeout ? httpTimeout : 300) * 1000); // default to 5 minutes. connect(&_timer, &QTimer::timeout, this, &AbstractNetworkJob::slotTimeout); diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index f9a856b63..cde76ceb5 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -294,7 +294,7 @@ QNetworkReply *Account::sendRawRequest(const QByteArray &verb, const QUrl &url, SimpleNetworkJob *Account::sendRequest(const QByteArray &verb, const QUrl &url, QNetworkRequest req, QIODevice *data) { - auto job = new SimpleNetworkJob(sharedFromThis(), this); + auto job = new SimpleNetworkJob(sharedFromThis()); job->startRequest(verb, url, req, data); return job; } @@ -621,7 +621,7 @@ void Account::fetchDirectEditors(const QUrl &directEditingURL, const QString &di if (!directEditingURL.isEmpty() && (directEditingETag.isEmpty() || directEditingETag != _lastDirectEditingETag)) { // Fetch the available editors and their mime types - auto *job = new JsonApiJob(sharedFromThis(), QLatin1String("ocs/v2.php/apps/files/api/v1/directEditing"), this); + auto *job = new JsonApiJob(sharedFromThis(), QLatin1String("ocs/v2.php/apps/files/api/v1/directEditing")); QObject::connect(job, &JsonApiJob::jsonReceived, this, &Account::slotDirectEditingRecieved); job->start(); } -- 2.30.2