X-Git-Url: http://git.maemo.org/git/?p=groove;a=blobdiff_plain;f=playlist.cpp;h=3d437a517f9b3b0d948cbab46dbda135b82396b4;hp=e79229d4fba730ef5410b649d068766a83872a69;hb=810ad0d7cae54b293ddebe4e3874fd2f0e6e38a1;hpb=4adbefb36e52cb33564e704d8ea6a49425db8caf diff --git a/playlist.cpp b/playlist.cpp index e79229d..3d437a5 100644 --- a/playlist.cpp +++ b/playlist.cpp @@ -18,11 +18,14 @@ void playlist::markPlayed(int position) void playlist::freeMemory(int position) { pList->at(position)->downloaded = false; + pList->at(position)->bufferready = false; delete pList->at(position)->buffer; pList->at(position)->buffer = new QBuffer(); } bool playlist::existAt(int position) { + if(position < 0) + return false; return (pList->size() > position); } @@ -43,7 +46,7 @@ void playlist::setBufferRdy(int b) } bool playlist::setCurrentPlaying(int position) { - if(pList->size() > position) + if(this->existAt(position)) { this->currentplayingitem = position; if(!pList->at(position)->downloaded && this->currentdownloaditem != this->currentplayingitem) @@ -59,7 +62,14 @@ bool playlist::setCurrentPlaying(int position) return true; } else + { + if(position = -1) + { + this->currentplayingitem = -1; + } + else return false; + } } QIODevice * playlist::getBuffer(int position) { @@ -90,7 +100,7 @@ void playlist::beginDownload(int position) void playlist::getNError(QNetworkReply::NetworkError error) { qDebug() << "Network Error (if this is 99 then it will retry" << error; - if(error == QNetworkReply::UnknownNetworkError) + if(error == QNetworkReply::UnknownNetworkError && this->currentdownloaditem != -1) beginDownload(this->currentdownloaditem); } @@ -134,7 +144,7 @@ int playlist::addSong(QStandardItem *item) void playlist::downloadDone(int position) { - if(this->existAt(position+1) && this->currentSkeyItem == -1) + if(this->existAt(position+1) && this->currentSkeyItem == -1 && !pList->at(position+1)->downloaded && this->currentdownloaditem != position+1) beginDownload(position+1); else this->currentdownloaditem = -1;