Check that popular_month_, popular_today_ and stations_ still exist (i.e. aren't NULL) when we receive replies.

Indeed, we do not need to be logged in to get results for popular songs and get stations tags. But if the user has been automatically logged out (e.g. session_id not valid anymore) these items have been deleted.
This commit is contained in:
Arnaud Bienner 2012-04-04 19:21:18 +02:00
parent 5f0f50435c
commit e0d61eb66c
1 changed files with 6 additions and 0 deletions

View File

@ -755,6 +755,8 @@ void GroovesharkService::PopularSongsMonthRetrieved(QNetworkReply* reply) {
reply->deleteLater(); reply->deleteLater();
QVariantMap result = ExtractResult(reply); QVariantMap result = ExtractResult(reply);
SongList songs = ExtractSongs(result); SongList songs = ExtractSongs(result);
if (!popular_month_)
return;
foreach (const Song& song, songs) { foreach (const Song& song, songs) {
QStandardItem* child = new QStandardItem(song.PrettyTitleWithArtist()); QStandardItem* child = new QStandardItem(song.PrettyTitleWithArtist());
child->setData(Type_Track, InternetModel::Role_Type); child->setData(Type_Track, InternetModel::Role_Type);
@ -783,6 +785,8 @@ void GroovesharkService::PopularSongsTodayRetrieved(QNetworkReply* reply) {
reply->deleteLater(); reply->deleteLater();
QVariantMap result = ExtractResult(reply); QVariantMap result = ExtractResult(reply);
SongList songs = ExtractSongs(result); SongList songs = ExtractSongs(result);
if (!popular_today_)
return;
foreach (const Song& song, songs) { foreach (const Song& song, songs) {
QStandardItem* child = new QStandardItem(song.PrettyTitleWithArtist()); QStandardItem* child = new QStandardItem(song.PrettyTitleWithArtist());
child->setData(Type_Track, InternetModel::Role_Type); child->setData(Type_Track, InternetModel::Role_Type);
@ -840,6 +844,8 @@ void GroovesharkService::AutoplayTagsRetrieved(QNetworkReply* reply) {
reply->deleteLater(); reply->deleteLater();
QVariantMap result = ExtractResult(reply); QVariantMap result = ExtractResult(reply);
QVariantMap::const_iterator it; QVariantMap::const_iterator it;
if (!stations_)
return;
for (it = result.constBegin(); it != result.constEnd(); ++it) { for (it = result.constBegin(); it != result.constEnd(); ++it) {
int id = it.key().toInt(); int id = it.key().toInt();
QString name = it.value().toString().toLower(); QString name = it.value().toString().toLower();