diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-09-19 11:39:30 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-09-19 12:57:32 +0900 |
commit | d4cb62523585137dee7879f2143ae1b4dd62513d (patch) | |
tree | cd44b07b917e50b24daf26e90048186fec4d58f4 | |
parent | 4e23da3de66e425997506c75204a9e3ea22ccfa5 (diff) | |
download | libquotient-d4cb62523585137dee7879f2143ae1b4dd62513d.tar.gz libquotient-d4cb62523585137dee7879f2143ae1b4dd62513d.zip |
Fix a race condition leading to a crash on close
It seems that some reply processing still might have happened after
BaseJob::abandon() (caused in turn by destroying a Connection object),
probably because the event from QNetworkReply landed in the event queue
after BaseJob::abandon() but before actual deletion of a job object. Now
countered by disconnecting from QNetworkReply signals in abandon() and
stop().
-rw-r--r-- | jobs/basejob.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp index 26ceb268..8c9ef222 100644 --- a/jobs/basejob.cpp +++ b/jobs/basejob.cpp @@ -219,16 +219,17 @@ BaseJob::Status BaseJob::parseJson(const QJsonDocument&) void BaseJob::stop() { d->timer.stop(); - if (!d->reply) + if (d->reply) { - qCWarning(d->logCat) << this << "stopped with empty network reply"; - } - else if (d->reply->isRunning()) - { - qCWarning(d->logCat) << this << "stopped without ready network reply"; d->reply->disconnect(this); // Ignore whatever comes from the reply - d->reply->abort(); + if (d->reply->isRunning()) + { + qCWarning(d->logCat) << this << "stopped without ready network reply"; + d->reply->abort(); + } } + else + qCWarning(d->logCat) << this << "stopped with empty network reply"; } void BaseJob::finishJob() @@ -320,6 +321,9 @@ void BaseJob::setStatus(int code, QString message) void BaseJob::abandon() { + this->disconnect(); + if (d->reply) + d->reply->disconnect(this); deleteLater(); } |