diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2016-09-11 20:10:34 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2016-09-11 20:10:34 +0900 |
commit | 107a5017149f8dbe7829e8e6d03a0e7a1124f281 (patch) | |
tree | c29820a98e05f4ec87bc3f9fc509c9e457368892 /jobs/basejob.cpp | |
parent | 763a7b3ed8b7e4562f10dc3d7c53ac35707ce5cb (diff) | |
download | libquotient-107a5017149f8dbe7829e8e6d03a0e7a1124f281.tar.gz libquotient-107a5017149f8dbe7829e8e6d03a0e7a1124f281.zip |
Explicitly stop the timer in finishJob()
This should avoid timeout event catching up on a not-yet-deleted-but-
already-invalid job object.
Diffstat (limited to 'jobs/basejob.cpp')
-rw-r--r-- | jobs/basejob.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp index 20b45a15..a3b69922 100644 --- a/jobs/basejob.cpp +++ b/jobs/basejob.cpp @@ -52,6 +52,8 @@ class BaseJob::Private QScopedPointer<QNetworkReply, NetworkReplyDeleter> reply; Status status; + + QTimer timer; }; inline QDebug operator<<(QDebug dbg, BaseJob* j) @@ -63,6 +65,7 @@ BaseJob::BaseJob(ConnectionData* connection, JobHttpType type, QString name, boo : d(new Private(connection, type, needsToken)) { setObjectName(name); + connect (&d->timer, &QTimer::timeout, this, &BaseJob::timeout); qDebug() << this << "created"; } @@ -115,7 +118,7 @@ void BaseJob::start() } connect( d->reply.data(), &QNetworkReply::sslErrors, this, &BaseJob::sslErrors ); connect( d->reply.data(), &QNetworkReply::finished, this, &BaseJob::gotReply ); - QTimer::singleShot( 120*1000, this, SLOT(timeout()) ); + d->timer.start( 120*1000 ); // connect( d->reply, static_cast<void(QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), // this, &BaseJob::networkError ); // http://doc.qt.io/qt-5/qnetworkreply.html#error-1 } @@ -163,6 +166,7 @@ BaseJob::Status BaseJob::parseJson(const QJsonDocument&) void BaseJob::finishJob(bool emitResult) { + d->timer.stop(); if (!d->reply) { qWarning() << this << "finishes with empty network reply"; |