From e5f0b56d07f13db6a4542ff5fa5a3e31e61169bc Mon Sep 17 00:00:00 2001 From: Maximilian Seidler <78690852+PaideiaDilemma@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:05:18 +0200 Subject: [PATCH] asyncResourceGatherer: trace logs and exit behaviour (#414) * asyncResourceGatherer: add trace logs useful for debugging label updates * label: remove unused onAssetCallbackTimer * asyncResourceGatherer: fix crashes on exit --- src/renderer/AsyncResourceGatherer.cpp | 11 +++++++---- src/renderer/widgets/Label.cpp | 5 ----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/renderer/AsyncResourceGatherer.cpp b/src/renderer/AsyncResourceGatherer.cpp index 59e593e..18282ff 100644 --- a/src/renderer/AsyncResourceGatherer.cpp +++ b/src/renderer/AsyncResourceGatherer.cpp @@ -385,6 +385,8 @@ void CAsyncResourceGatherer::asyncAssetSpinLock() { // process requests for (auto& r : requests) { + Debug::log(TRACE, "Processing requested resourceID {}", r.id); + if (r.type == TARGET_TEXT) { renderText(r); } else if (r.type == TARGET_IMAGE) { @@ -399,11 +401,11 @@ void CAsyncResourceGatherer::asyncAssetSpinLock() { g_pHyprlock->addTimer(std::chrono::milliseconds(0), timerCallback, new STimerCallbackData{r.callback, r.callbackData}); } } - - dmas.clear(); } void CAsyncResourceGatherer::requestAsyncAssetPreload(const SPreloadRequest& request) { + Debug::log(TRACE, "Requesting label resource {}", request.id); + std::lock_guard lg(asyncLoopState.requestsMutex); asyncLoopState.requests.push_back(request); asyncLoopState.pending = true; @@ -416,13 +418,14 @@ void CAsyncResourceGatherer::unloadAsset(SPreloadedAsset* asset) { void CAsyncResourceGatherer::notify() { std::lock_guard lg(asyncLoopState.requestsMutex); + asyncLoopState.requests.clear(); asyncLoopState.pending = true; asyncLoopState.requestsCV.notify_all(); } void CAsyncResourceGatherer::await() { - if (asyncLoopThread.joinable()) - asyncLoopThread.join(); if (initialGatherThread.joinable()) initialGatherThread.join(); + if (asyncLoopThread.joinable()) + asyncLoopThread.join(); } diff --git a/src/renderer/widgets/Label.cpp b/src/renderer/widgets/Label.cpp index b7f7c7f..adc09ed 100644 --- a/src/renderer/widgets/Label.cpp +++ b/src/renderer/widgets/Label.cpp @@ -147,11 +147,6 @@ bool CLabel::draw(const SRenderData& data) { return false; } -static void onAssetCallbackTimer(std::shared_ptr self, void* data) { - const auto PLABEL = (CLabel*)data; - PLABEL->renderSuper(); -} - void CLabel::renderSuper() { g_pHyprlock->renderOutput(outputStringPort); }