From: lx-s Date: Wed, 8 Jul 2026 08:43:11 +0000 (+0200) Subject: Fixed possible block on wndMutex in WMLog. X-Git-Tag: 2.6.0.0~84 X-Git-Url: https://repos.lx-s.de/gitweb/?a=commitdiff_plain;h=b3e6ec5383b1f8f661d0dffed7ce73e8262a98df;p=winmute.git Fixed possible block on wndMutex in WMLog. --- diff --git a/WinMute/WMLog.cpp b/WinMute/WMLog.cpp index 3cbbb50..7f65dff 100644 --- a/WinMute/WMLog.cpp +++ b/WinMute/WMLog.cpp @@ -156,8 +156,15 @@ void WMLog::StoreMessage(LogLevel level, const wchar_t* msg) } { - const std::scoped_lock lock(wndMutex_); - for (const auto hWnd : registeredWindows_) { + // Copy the window list first: holding wndMutex_ across SendMessageW + // deadlocks if the UI thread is simultaneously blocked on wndMutex_ + // in (Un)RegisterForLogUpdates. + std::vector logWindows; + { + const std::scoped_lock lock(wndMutex_); + logWindows = registeredWindows_; + } + for (const auto hWnd : logWindows) { if (IsWindow(hWnd)) { SendMessageW(hWnd, WM_LOG_UPDATED, 0, reinterpret_cast(&lm)); }