mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-05 21:55:24 +00:00
Added some boundry checking to BrowseLayout and PlaybackService, which should fix the empty library crash.
This commit is contained in:
parent
c6610585b7
commit
4d38d4f9ee
@ -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)") {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user