Fixed crash related to removing tracks from the library that are

currently in the play queue.
This commit is contained in:
casey 2016-07-04 12:02:06 -07:00
parent cb32bb1640
commit bf1c9a0528

View File

@ -54,6 +54,9 @@ using namespace musik::core::audio;
using namespace musik::core::library; using namespace musik::core::library;
using namespace musik::box; using namespace musik::box;
using namespace cursespp; using namespace cursespp;
static IScrollAdapter::EntryPtr MISSING_ENTRY = IScrollAdapter::EntryPtr();
TrackListView::TrackListView( TrackListView::TrackListView(
PlaybackService& playback, PlaybackService& playback,
LibraryPtr library, LibraryPtr library,
@ -66,6 +69,12 @@ TrackListView::TrackListView(
this->adapter = new Adapter(*this); this->adapter = new Adapter(*this);
this->lastQueryHash = 0; this->lastQueryHash = 0;
this->formatter = formatter; this->formatter = formatter;
if (!MISSING_ENTRY) {
auto e = std::shared_ptr<SingleLineEntry>(new SingleLineEntry("track missing"));
e->SetAttrs(COLOR_PAIR(CURSESPP_TEXT_ERROR));
MISSING_ENTRY = e;
}
} }
TrackListView::~TrackListView() { TrackListView::~TrackListView() {
@ -200,6 +209,10 @@ IScrollAdapter::EntryPtr TrackListView::Adapter::GetEntry(size_t index) {
TrackPtr track = parent.metadata->Get(index); TrackPtr track = parent.metadata->Get(index);
if (!track) {
return MISSING_ENTRY;
}
TrackPtr playing = parent.playing; TrackPtr playing = parent.playing;
if (playing && if (playing &&
playing->Id() == track->Id() && playing->Id() == track->Id() &&