From dfc707053eff22b0af3a9f4b2a85c684d68a99aa Mon Sep 17 00:00:00 2001 From: Elias Woods Date: Thu, 1 Jul 2010 03:16:54 -0400 Subject: [PATCH] Fixed download bug --- Groove.pro.user | 4 ++-- playlist.cpp | 19 +++++++++++++++++-- playlist.h | 1 + 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Groove.pro.user b/Groove.pro.user index ecdfbb8..9863bf3 100644 --- a/Groove.pro.user +++ b/Groove.pro.user @@ -2,7 +2,7 @@ ProjectExplorer.Project.ActiveTarget - 1 + 0 ProjectExplorer.Project.EditorSettings @@ -194,7 +194,7 @@ 1 - 2010-07-01T01:31:56 + 2010-07-01T03:13:16 diff --git a/playlist.cpp b/playlist.cpp index 3004f86..3c9f6ea 100644 --- a/playlist.cpp +++ b/playlist.cpp @@ -73,16 +73,24 @@ void playlist::beginDownload(int position) req.setHeader(req.ContentTypeHeader,QVariant("application/x-www-form-urlencoded")); if(reply) { - reply->abort(); - delete reply; + reply->disconnect(); + reply->deleteLater(); } reply = manager->post(req,QString("streamKey=" + pList->at(this->currentdownloaditem)->streamkey->toAscii()).toAscii()); pList->at(this->currentdownloaditem)->buffer->open(QBuffer::ReadWrite | QBuffer::Truncate); connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(downloadSlot(qint64,qint64))); connect(reply,SIGNAL(finished()),this,SLOT(networkReplyFinish())); connect(this,SIGNAL(downloadComplete(int)),this,SLOT(downloadDone(int))); + connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(getNError(QNetworkReply::NetworkError))); startStreamT = QTime::currentTime(); } +void playlist::getNError(QNetworkReply::NetworkError error) +{ + qDebug() << "Network Error (if this is 99 then it will retry" << error; + if(error == QNetworkReply::UnknownNetworkError) + beginDownload(this->currentdownloaditem); + +} void playlist::setGscom(gscom *comm) { @@ -138,10 +146,17 @@ void playlist::networkReplyFinish() QNetworkRequest req; req.setUrl(url.toUrl()); qDebug() << url; + if(reply) + { + reply->disconnect(); + reply->deleteLater(); + } reply = manager->get(req); startStreamT = QTime::currentTime(); //connect(reply,SIGNAL(finished()),this,SLOT(start())); connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(downloadSlot(qint64,qint64))); + connect(reply,SIGNAL(finished()),this,SLOT(networkReplyFinish())); + connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(getNError(QNetworkReply::NetworkError))); } } diff --git a/playlist.h b/playlist.h index 2fe1acb..48966ff 100644 --- a/playlist.h +++ b/playlist.h @@ -50,6 +50,7 @@ private slots: void downloadDone(int position); void skeyFound(); void setBufferRdy(int b); + void getNError(QNetworkReply::NetworkError); private: -- 1.7.9.5