diff --git a/src/musikcore/library/LocalLibrary.cpp b/src/musikcore/library/LocalLibrary.cpp index 0bc90f877..91e040c4d 100644 --- a/src/musikcore/library/LocalLibrary.cpp +++ b/src/musikcore/library/LocalLibrary.cpp @@ -46,7 +46,6 @@ static const std::string TAG = "LocalLibrary"; static bool scheduleSyncDueToDbUpgrade = false; -static int kWaitIndefinite = std::numeric_limits::max(); using namespace musik::core; using namespace musik::core::library; diff --git a/src/musikcore/library/RemoteLibrary.cpp b/src/musikcore/library/RemoteLibrary.cpp index 643ba8441..16f9f00bc 100644 --- a/src/musikcore/library/RemoteLibrary.cpp +++ b/src/musikcore/library/RemoteLibrary.cpp @@ -275,6 +275,7 @@ void RemoteLibrary::OnQueryCompleted(const std::string& messageId, Query query) } void RemoteLibrary::RunQuery(QueryContextPtr context) { + std::unique_lock lock(this->queueMutex); #if 0 this->RunQueryOnLoopback(context); #else @@ -315,7 +316,6 @@ void RemoteLibrary::RunQueryOnLoopback(QueryContextPtr context) { void RemoteLibrary::RunQueryOnWebSocketClient(QueryContextPtr context) { if (context->query) { - std::unique_lock lock(this->queueMutex); const std::string messageId = wsc.EnqueueQuery(context->query); if (messageId.size()) { queriesInFlight[messageId] = context; diff --git a/src/musikcore/library/track/TrackList.cpp b/src/musikcore/library/track/TrackList.cpp index 7b88b7bc2..bcac58745 100755 --- a/src/musikcore/library/track/TrackList.cpp +++ b/src/musikcore/library/track/TrackList.cpp @@ -277,23 +277,33 @@ void TrackList::CacheWindow(size_t from, size_t to, bool async) const { if (async) { currentWindow.Set(from, to); auto shared = shared_from_this(); /* ensure we remain alive for the duration of the query */ - this->library->EnqueueAndWait(query, 50LL, [this, shared, from, to, query](auto q) { + bool completionFinished = false; + auto completion = [this, &completionFinished, shared, from, to, query](auto q) { + if (completionFinished) { + return; + } if (query->GetStatus() == IQuery::Finished) { auto& result = query->Result(); for (auto& kv : result) { this->AddToCache(kv.first, kv.second); } } - this->currentWindow.Reset(); if (this->nextWindow.Valid()) { size_t from = nextWindow.from, to = nextWindow.to; nextWindow.Reset(); this->CacheWindow(from, to, true); } - this->WindowCached(const_cast(this), from, to); - }); + completionFinished = true; + }; + + this->library->EnqueueAndWait(query, 75LL, completion); + + auto status = query->GetStatus(); + if (status != IQuery::Idle && status != IQuery::Running) { + completion(query); + } } else { this->library->EnqueueAndWait(query); diff --git a/src/musikcube/app/util/TrackRowRenderers.cpp b/src/musikcube/app/util/TrackRowRenderers.cpp index c50938a44..9ee40e7c0 100644 --- a/src/musikcube/app/util/TrackRowRenderers.cpp +++ b/src/musikcube/app/util/TrackRowRenderers.cpp @@ -54,7 +54,7 @@ using namespace cursespp; #define DIGITS(x) (x > 9 ? (int) log10((double) x) + 1 : 1) static const bool kEnableSkeletonRows = true; -static const std::string kSkeletonChar = "░"; +static const std::string kSkeletonChar = "-"; // "░"; static const int kDurationColWidth = 5; /* 00:00 */ static const int kRatingBreakpointWidth = 90; diff --git a/src/musikcube/app/window/TrackListView.cpp b/src/musikcube/app/window/TrackListView.cpp index 4021ebdc6..c23bfb424 100755 --- a/src/musikcube/app/window/TrackListView.cpp +++ b/src/musikcube/app/window/TrackListView.cpp @@ -51,6 +51,7 @@ #include #define WINDOW_MESSAGE_SCROLL_TO_PLAYING 1003 +#define WINDOW_MESSAGE_TRACK_LIST_WINDOW_CACHED 1004 /* this is pretty gross, but i think we'll eventually settle on one versus the other and i don't want to bother adding a bunch of annoying infrastructure to more @@ -123,7 +124,7 @@ void TrackListView::SetRowRenderer(TrackRowRenderers::Renderer renderer) { } void TrackListView::OnTrackListWindowCached(const musik::core::TrackList* track, size_t from, size_t to) { - this->Redraw(); + this->Debounce(WINDOW_MESSAGE_TRACK_LIST_WINDOW_CACHED, 0, 0, 50); } void TrackListView::OnQueryCompleted(IQuery* query) { @@ -243,6 +244,9 @@ void TrackListView::ProcessMessage(IMessage &message) { if (message.Type() == WINDOW_MESSAGE_SCROLL_TO_PLAYING) { this->ScrollToPlaying(); } + else if (message.Type() == WINDOW_MESSAGE_TRACK_LIST_WINDOW_CACHED) { + this->Redraw(); + } else { ListWindow::ProcessMessage(message); }