From cb4317973039d6b891aabcd20cf2b82a770af809 Mon Sep 17 00:00:00 2001 From: Flavio Date: Sun, 1 Jan 2012 17:05:51 +0100 Subject: [PATCH] Fixes for multithreaded HTTP in Qt 4.8 --- src/downloaditem.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/downloaditem.cpp b/src/downloaditem.cpp index 8e66e29..fe8b3b6 100644 --- a/src/downloaditem.cpp +++ b/src/downloaditem.cpp @@ -31,8 +31,14 @@ DownloadItem::DownloadItem(Video *video, QUrl url, QString filename, QObject *pa } DownloadItem::~DownloadItem() { - if (m_reply) delete m_reply; - if (video) delete video; + if (m_reply) { + delete m_reply; + m_reply = 0; + } + if (video) { + delete video; + video = 0; + } } void DownloadItem::start() { @@ -111,6 +117,7 @@ void DownloadItem::tryAgain() { } void DownloadItem::downloadReadyRead() { + if (!m_reply) return; if (!m_file.isOpen()) { if (!m_file.open(QIODevice::ReadWrite)) { @@ -156,6 +163,7 @@ QString DownloadItem::errorMessage() const { } void DownloadItem::metaDataChanged() { + if (!m_reply) return; QVariant locationHeader = m_reply->header(QNetworkRequest::LocationHeader); if (locationHeader.isValid()) { m_url = locationHeader.toUrl(); -- 2.39.5