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
This commit is contained in:
Olivier Goffart 2018-11-22 08:46:33 +01:00 committed by Kevin Ottens
parent 6b0bb66b17
commit 7c1871ae65
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
2 changed files with 5 additions and 2 deletions

View file

@ -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);

View file

@ -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();
}