diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2016-05-06 22:35:59 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2016-05-06 22:35:59 +0900 |
commit | a3be7715910434cd8ef9d626b8c9c518e2d5fc40 (patch) | |
tree | ddc09a6c55c001bc54d72cbbb0e53f801d11397c /jobs | |
parent | f638c58545ee0a159cae3e91e1ccb3089945930e (diff) | |
download | libquotient-a3be7715910434cd8ef9d626b8c9c518e2d5fc40.tar.gz libquotient-a3be7715910434cd8ef9d626b8c9c518e2d5fc40.zip |
Make sure the QNetworkReply object is aborted at any failure and even silent destruction of the job
Diffstat (limited to 'jobs')
-rw-r--r-- | jobs/basejob.cpp | 9 | ||||
-rw-r--r-- | jobs/basejob.h | 3 |
2 files changed, 9 insertions, 3 deletions
diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp index e24db012..bcfd5875 100644 --- a/jobs/basejob.cpp +++ b/jobs/basejob.cpp @@ -54,7 +54,11 @@ BaseJob::BaseJob(ConnectionData* connection, JobHttpType type, bool needsToken) BaseJob::~BaseJob() { if( d->reply ) + { + if( d->reply->isRunning() ) + d->reply->abort(); d->reply->deleteLater(); + } delete d; } @@ -115,6 +119,8 @@ void BaseJob::fail(int errorCode, QString errorString) { setError( errorCode ); setErrorText( errorString ); + if( d->reply->isRunning() ) + d->reply->abort(); emitResult(); } @@ -149,8 +155,7 @@ void BaseJob::gotReply() void BaseJob::timeout() { qDebug() << "Timeout!"; - if( d->reply->isRunning() ) - d->reply->abort(); + fail( TimeoutError, "The job has timed out" ); } void BaseJob::sslErrors(const QList<QSslError>& errors) diff --git a/jobs/basejob.h b/jobs/basejob.h index f343c769..f1ad66d1 100644 --- a/jobs/basejob.h +++ b/jobs/basejob.h @@ -45,7 +45,8 @@ namespace QMatrixClient void start() override; - enum ErrorCode { NetworkError = KJob::UserDefinedError, JsonParseError, UserDefinedError }; + enum ErrorCode { NetworkError = KJob::UserDefinedError, + JsonParseError, TimeoutError, UserDefinedError }; signals: /** |