1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-31 03:27:40 +01:00

Fix a crash and a never-ending task when expanding the Grooveshark item for the first time with an invalid or expired session.

This commit is contained in:
David Sansome 2012-06-02 13:21:56 +01:00
parent eeb617e892
commit 150d5a124a

View File

@ -716,6 +716,11 @@ void GroovesharkService::RetrieveUserFavorites() {
void GroovesharkService::UserFavoritesRetrieved(QNetworkReply* reply, int task_id) { void GroovesharkService::UserFavoritesRetrieved(QNetworkReply* reply, int task_id) {
reply->deleteLater(); reply->deleteLater();
if (!favorites_) {
// The use probably logged out before the response arrived.
return;
}
favorites_->removeRows(0, favorites_->rowCount()); favorites_->removeRows(0, favorites_->rowCount());
QVariantMap result = ExtractResult(reply); QVariantMap result = ExtractResult(reply);
@ -752,8 +757,15 @@ 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);
app_->task_manager()->IncreaseTaskProgress(task_popular_id_, 50, 100);
if (app_->task_manager()->GetTaskProgress(task_popular_id_) >= 100) {
app_->task_manager()->SetTaskFinished(task_popular_id_);
}
if (!popular_month_) if (!popular_month_)
return; 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);
@ -763,11 +775,6 @@ void GroovesharkService::PopularSongsMonthRetrieved(QNetworkReply* reply) {
popular_month_->appendRow(child); popular_month_->appendRow(child);
} }
app_->task_manager()->IncreaseTaskProgress(task_popular_id_, 50, 100);
if (app_->task_manager()->GetTaskProgress(task_popular_id_) >= 100) {
app_->task_manager()->SetTaskFinished(task_popular_id_);
}
} }
void GroovesharkService::RetrievePopularSongsToday() { void GroovesharkService::RetrievePopularSongsToday() {
@ -782,8 +789,15 @@ 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);
app_->task_manager()->IncreaseTaskProgress(task_popular_id_, 50, 100);
if (app_->task_manager()->GetTaskProgress(task_popular_id_) >= 100) {
app_->task_manager()->SetTaskFinished(task_popular_id_);
}
if (!popular_today_) if (!popular_today_)
return; 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);
@ -793,11 +807,6 @@ void GroovesharkService::PopularSongsTodayRetrieved(QNetworkReply* reply) {
popular_today_->appendRow(child); popular_today_->appendRow(child);
} }
app_->task_manager()->IncreaseTaskProgress(task_popular_id_, 50, 100);
if (app_->task_manager()->GetTaskProgress(task_popular_id_) >= 100) {
app_->task_manager()->SetTaskFinished(task_popular_id_);
}
} }
void GroovesharkService::RetrieveSubscribedPlaylists() { void GroovesharkService::RetrieveSubscribedPlaylists() {