Ignore GS search's result if it's not the last one

This commit is contained in:
Arnaud Bienner 2012-10-14 23:27:45 +02:00
parent 8eb787a2eb
commit b9606d8a06
1 changed files with 6 additions and 3 deletions

View File

@ -275,14 +275,17 @@ void GroovesharkService::DoSearch() {
<< Param("country", "")
<< Param("limit", QString::number(kSongSearchLimit))
<< Param("offset", "");
QNetworkReply* reply = CreateRequest("getSongSearchResults", parameters);
NewClosure(reply, SIGNAL(finished()), this,
SLOT(SearchSongsFinished(QNetworkReply*)), reply);
last_search_reply_ = CreateRequest("getSongSearchResults", parameters);
NewClosure(last_search_reply_, SIGNAL(finished()), this,
SLOT(SearchSongsFinished(QNetworkReply*)), last_search_reply_);
}
void GroovesharkService::SearchSongsFinished(QNetworkReply* reply) {
reply->deleteLater();
if (reply != last_search_reply_)
return;
QVariantMap result = ExtractResult(reply);
SongList songs = ExtractSongs(result);
app_->task_manager()->SetTaskFinished(task_search_id_);