diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 2f545a982..6a6d0d2b7 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,6 @@ 0.9.1 +* added an app icon on win32 and android builds * added proper support for using and switching between different audio sample formats. 24/192k works across all platforms now. * fixed `DirectSoundOut` pause to work properly again @@ -7,6 +8,7 @@ macOS binaries that don't require homebrew! let's try to keep it that way. * updated some defaults -- rescan metadata on startup by default, and restrict to two processing threads. +* fixed a crash when trying to change tracks in an empty playlist queue -------------------------------------------------------------------------------- diff --git a/src/core/library/track/TrackList.cpp b/src/core/library/track/TrackList.cpp index e21e8577b..4e86de8ef 100755 --- a/src/core/library/track/TrackList.cpp +++ b/src/core/library/track/TrackList.cpp @@ -125,19 +125,24 @@ bool TrackList::Delete(size_t index) { } TrackPtr TrackList::Get(size_t index) const { - auto id = this->ids.at(index); - auto cached = this->GetFromCache(id); + try { + auto id = this->ids.at(index); + auto cached = this->GetFromCache(id); - if (cached) { - return cached; + if (cached) { + return cached; + } + + std::shared_ptr query( + new TrackMetadataQuery(id, this->library)); + + this->library->Enqueue(query, ILibrary::QuerySynchronous); + this->AddToCache(id, query->Result()); + return query->Result(); + } + catch (...) { + return TrackPtr(); } - - std::shared_ptr query( - new TrackMetadataQuery(id, this->library)); - - this->library->Enqueue(query, ILibrary::QuerySynchronous); - this->AddToCache(id, query->Result()); - return query->Result(); } IRetainedTrack* TrackList::GetRetainedTrack(size_t index) const {