From 4730f54df7edf4775dfddf45f77c60edd86c32d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 8 Feb 2015 17:56:14 +0100 Subject: SCRATCH separate the generic updater logic from the application --- logic/net/ByteArrayDownload.cpp | 2 +- logic/net/CacheDownload.cpp | 2 +- logic/net/MD5EtagDownload.cpp | 2 +- logic/net/NetAction.h | 3 ++- logic/net/NetJob.cpp | 4 ++-- logic/net/NetJob.h | 1 + 6 files changed, 8 insertions(+), 6 deletions(-) (limited to 'logic/net') diff --git a/logic/net/ByteArrayDownload.cpp b/logic/net/ByteArrayDownload.cpp index 9f71f911..7a41ee28 100644 --- a/logic/net/ByteArrayDownload.cpp +++ b/logic/net/ByteArrayDownload.cpp @@ -31,7 +31,7 @@ void ByteArrayDownload::start() auto worker = ENV.qnam(); QNetworkReply *rep = worker->get(request); - m_reply = std::shared_ptr(rep); + m_reply.reset(rep); connect(rep, SIGNAL(downloadProgress(qint64, qint64)), SLOT(downloadProgress(qint64, qint64))); connect(rep, SIGNAL(finished()), SLOT(downloadFinished())); diff --git a/logic/net/CacheDownload.cpp b/logic/net/CacheDownload.cpp index 6ddfc55f..0bbe75c3 100644 --- a/logic/net/CacheDownload.cpp +++ b/logic/net/CacheDownload.cpp @@ -77,7 +77,7 @@ void CacheDownload::start() auto worker = ENV.qnam(); QNetworkReply *rep = worker->get(request); - m_reply = std::shared_ptr(rep); + m_reply.reset(rep); connect(rep, SIGNAL(downloadProgress(qint64, qint64)), SLOT(downloadProgress(qint64, qint64))); connect(rep, SIGNAL(finished()), SLOT(downloadFinished())); diff --git a/logic/net/MD5EtagDownload.cpp b/logic/net/MD5EtagDownload.cpp index 6e1d0cfc..03752ea8 100644 --- a/logic/net/MD5EtagDownload.cpp +++ b/logic/net/MD5EtagDownload.cpp @@ -86,7 +86,7 @@ void MD5EtagDownload::start() auto worker = ENV.qnam(); QNetworkReply *rep = worker->get(request); - m_reply = std::shared_ptr(rep); + m_reply.reset(rep); connect(rep, SIGNAL(downloadProgress(qint64, qint64)), SLOT(downloadProgress(qint64, qint64))); connect(rep, SIGNAL(finished()), SLOT(downloadFinished())); diff --git a/logic/net/NetAction.h b/logic/net/NetAction.h index 81cb1bdb..b306bdfe 100644 --- a/logic/net/NetAction.h +++ b/logic/net/NetAction.h @@ -19,6 +19,7 @@ #include #include #include +#include enum JobStatus { @@ -58,7 +59,7 @@ public: public: /// the network reply - std::shared_ptr m_reply; + QObjectPtr m_reply; /// the content of the content-type header QString m_content_type; diff --git a/logic/net/NetJob.cpp b/logic/net/NetJob.cpp index e10afbc8..5a50b876 100644 --- a/logic/net/NetJob.cpp +++ b/logic/net/NetJob.cpp @@ -29,7 +29,7 @@ void NetJob::partSucceeded(int index) m_doing.remove(index); m_done.insert(index); - disconnect(downloads[index].get(), 0, this, 0); + downloads[index].get()->disconnect(this); startMoreParts(); } @@ -46,7 +46,7 @@ void NetJob::partFailed(int index) slot.failures++; m_todo.enqueue(index); } - disconnect(downloads[index].get(), 0, this, 0); + downloads[index].get()->disconnect(this); startMoreParts(); } diff --git a/logic/net/NetJob.h b/logic/net/NetJob.h index 0d8b7fbd..708afa79 100644 --- a/logic/net/NetJob.h +++ b/logic/net/NetJob.h @@ -108,6 +108,7 @@ private: qint64 current_progress = 0; qint64 total_progress = 1; int failures = 0; + bool connected = false; }; QString m_job_name; QList downloads; -- cgit v1.2.3