From a50db6d56d054d8c93abfd22e721d1edc9f38e3d Mon Sep 17 00:00:00 2001 From: Maximilian Seidler <78690852+PaideiaDilemma@users.noreply.github.com> Date: Tue, 9 Apr 2024 12:14:04 +0200 Subject: [PATCH] core: avoid double unlocks with no_fade_out (#257) --- src/core/hyprlock.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/core/hyprlock.cpp b/src/core/hyprlock.cpp index c029ddb..4dccce1 100644 --- a/src/core/hyprlock.cpp +++ b/src/core/hyprlock.cpp @@ -358,8 +358,10 @@ void CHyprlock::run() { g_pRenderer = std::make_unique(); - const auto CURRENTDESKTOP = getenv("XDG_CURRENT_DESKTOP"); - const auto SZCURRENTD = std::string{CURRENTDESKTOP ? CURRENTDESKTOP : ""}; + const auto CURRENTDESKTOP = getenv("XDG_CURRENT_DESKTOP"); + const auto SZCURRENTD = std::string{CURRENTDESKTOP ? CURRENTDESKTOP : ""}; + static auto* const PNOFADEOUT = (Hyprlang::INT* const*)g_pConfigManager->getValuePtr("general:no_fade_out"); + const bool NOFADEOUT = **PNOFADEOUT; Debug::log(LOG, "Running on {}", SZCURRENTD); @@ -452,15 +454,19 @@ void CHyprlock::run() { m_sLoopState.event = true; // let it process once - while (1) { + while (!m_bTerminate) { std::unique_lock lk(m_sLoopState.eventRequestMutex); if (m_sLoopState.event == false) m_sLoopState.loopCV.wait_for(lk, std::chrono::milliseconds(5000), [this] { return m_sLoopState.event; }); - if (m_bTerminate || (std::chrono::system_clock::now() > m_tFadeEnds && m_bFadeStarted)) { + if (!NOFADEOUT && m_bFadeStarted && std::chrono::system_clock::now() > m_tFadeEnds) { releaseSessionLock(); break; } + + if (m_bTerminate) + break; + std::lock_guard lg(m_sLoopState.eventLoopMutex); m_sLoopState.event = false; @@ -506,7 +512,7 @@ void CHyprlock::run() { passed.clear(); - if (m_bTerminate || (std::chrono::system_clock::now() > m_tFadeEnds && m_bFadeStarted)) { + if (!NOFADEOUT && m_bFadeStarted && std::chrono::system_clock::now() > m_tFadeEnds) { releaseSessionLock(); break; }