Added some boundry checking to BrowseLayout and PlaybackService, which should fix the empty library crash.

This commit is contained in:
casey 2016-06-13 16:42:57 -07:00
parent c6610585b7
commit 4d38d4f9ee
2 changed files with 11 additions and 5 deletions

View File

@ -142,12 +142,16 @@ void BrowseLayout::OnCategoryViewInvalidated(
bool BrowseLayout::KeyPress(const std::string& key) {
if (key == "^M") { /* enter. play the selection */
auto tracks = this->trackList->GetTrackList();
auto focus = this->GetFocus();
size_t index = (focus == this->trackList)
? this->trackList->GetSelectedIndex() : 0;
if (tracks && tracks->size()) {
auto focus = this->GetFocus();
size_t index = (focus == this->trackList)
? this->trackList->GetSelectedIndex() : 0;
this->playback.Play(*tracks, index);
}
this->playback.Play(*tracks, index);
return true;
}
if (key == "KEY_F(5)") {

View File

@ -137,7 +137,9 @@ void PlaybackService::Play(std::vector<TrackPtr>& tracks, size_t index) {
std::swap(temp, this->playlist);
}
this->Play(index);
if (index <= tracks.size()) {
this->Play(index);
}
}
void PlaybackService::Copy(std::vector<musik::core::TrackPtr>& target) {