]> git.sur5r.net Git - minitube/commitdiff
Fixes for multithreaded HTTP in Qt 4.8
authorFlavio <flavio@odisseo.local>
Sun, 1 Jan 2012 16:05:51 +0000 (17:05 +0100)
committerFlavio <flavio@odisseo.local>
Sun, 1 Jan 2012 16:05:51 +0000 (17:05 +0100)
src/downloaditem.cpp

index 8e66e294926764ef765cc46199bb090cc5dbc832..fe8b3b654a8f0869016a670bbd58c2b8028f432b 100644 (file)
@@ -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();