Avoid setting the reply as member.

This commit is contained in:
2025-04-09 23:31:21 +02:00
parent e2742d5633
commit 9380e95126
2 changed files with 6 additions and 5 deletions
+6 -4
View File
@@ -18,9 +18,9 @@ void DownloadJob::start()
{
assert(m_sourceUrl.isValid());
QNetworkRequest request(m_sourceUrl);
m_reply = m_net->get(request);
connect (m_reply, &QNetworkReply::finished, this, [=]() {
if (m_reply->error() != QNetworkReply::NoError) {
auto reply = m_net->get(request);
connect (reply, &QNetworkReply::finished, this, [=]() {
if (reply->error() != QNetworkReply::NoError) {
// TODO mark file as not available somehow.
logCritical() << "Download failed" << m_sourceUrl.toString();
}
@@ -32,9 +32,11 @@ void DownloadJob::start()
if (!out.open(QIODevice::WriteOnly)) {
logCritical() << "Opening file for writing failed" << m_targetFilePath;
}
out.write(m_reply->readAll());
out.write(reply->readAll());
out.flush();
}
reply->deleteLater();
deleteLater();
emit this->finished();
});
}
-1
View File
@@ -27,7 +27,6 @@ private:
QString m_targetFilePath;
QUrl m_sourceUrl;
QNetworkReply *m_reply = nullptr;
QNetworkAccessManager *m_net;
};