From 4d33e5a476f6d3f7ef6ae38e28401fef9102396a Mon Sep 17 00:00:00 2001 From: lx-s Date: Fri, 29 Sep 2023 08:48:50 +0200 Subject: [PATCH] Fixed crash on signout Fixes #25 --- WinMute/MuteControl.cpp | 2 +- WinMute/WinMute.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/WinMute/MuteControl.cpp b/WinMute/MuteControl.cpp index 87937e9..77bfb65 100644 --- a/WinMute/MuteControl.cpp +++ b/WinMute/MuteControl.cpp @@ -68,7 +68,7 @@ static LRESULT CALLBACK MuteControlWndProc( WPARAM wParam, LPARAM lParam) { - auto wm = reinterpret_cast(GetWindowLongPtr(hWnd, GWLP_USERDATA)); + auto wm = reinterpret_cast(GetWindowLongPtr(hWnd, GWLP_USERDATA)); switch (msg) { case WM_NCCREATE: { diff --git a/WinMute/WinMute.cpp b/WinMute/WinMute.cpp index e2eb95e..7cad7a9 100644 --- a/WinMute/WinMute.cpp +++ b/WinMute/WinMute.cpp @@ -542,10 +542,14 @@ LRESULT CALLBACK WinMute::WindowProc( } return TRUE; case WM_QUERYENDSESSION: - if (lParam == 0) { // Shutdown - muteCtrl_.NotifyShutdown(); - } else if ((lParam & ENDSESSION_LOGOFF)) { - muteCtrl_.NotifyLogout(); + return TRUE; + case WM_ENDSESSION: + if (wParam == TRUE) { + if (lParam == 0) { // Shutdown + muteCtrl_.NotifyShutdown(); + } else if ((lParam & ENDSESSION_LOGOFF)) { + muteCtrl_.NotifyLogout(); + } } break; case WM_WINMUTE_QUIETHOURS_START: -- 2.43.0