Fix crash when trying to download a track, but there is no current one playing.

This commit is contained in:
Andreas 2015-04-24 15:31:09 +02:00
parent 30346e7810
commit c9b39e7c83
1 changed files with 12 additions and 4 deletions

View File

@ -64,15 +64,23 @@ SongSender::~SongSender() {
}
void SongSender::SendSongs(const pb::remote::RequestDownloadSongs& request) {
Song current_song = app_->player()->GetCurrentItem()->Metadata();
Song current_song;
if (app_->player()->GetCurrentItem()) {
current_song = app_->player()->GetCurrentItem()->Metadata();
}
switch (request.download_item()) {
case pb::remote::CurrentItem: {
DownloadItem item(current_song, 1, 1);
download_queue_.append(item);
if (current_song.is_valid()) {
DownloadItem item(current_song, 1, 1);
download_queue_.append(item);
}
break;
}
case pb::remote::ItemAlbum:
SendAlbum(current_song);
if (current_song.is_valid()) {
SendAlbum(current_song);
}
break;
case pb::remote::APlaylist:
SendPlaylist(request.playlist_id());