diff --git a/src/Magpie.Core/ExclModeHelper.cpp b/src/Magpie.Core/ExclModeHelper.cpp index 0d0e7dec..ea9cd92e 100644 --- a/src/Magpie.Core/ExclModeHelper.cpp +++ b/src/Magpie.Core/ExclModeHelper.cpp @@ -39,11 +39,13 @@ wil::unique_mutex_nothrow ExclModeHelper::EnterExclMode() noexcept { hr = SHQueryUserNotificationState(&state); if (FAILED(hr)) { Logger::Get().ComError("SHQueryUserNotificationState 失败", hr); + exclModeMutex.ReleaseMutex(); exclModeMutex.reset(); return exclModeMutex; } if (state != QUNS_RUNNING_D3D_FULL_SCREEN) { Logger::Get().Error("模拟独占全屏失败"); + exclModeMutex.ReleaseMutex(); exclModeMutex.reset(); return exclModeMutex; } diff --git a/src/Magpie.Core/ScalingWindow.cpp b/src/Magpie.Core/ScalingWindow.cpp index b7a0254d..e7034813 100644 --- a/src/Magpie.Core/ScalingWindow.cpp +++ b/src/Magpie.Core/ScalingWindow.cpp @@ -412,6 +412,7 @@ LRESULT ScalingWindow::_MessageHandler(UINT msg, WPARAM wParam, LPARAM lParam) n } case WM_DESTROY: { + _exclModeMutex.ReleaseMutex(); _exclModeMutex.reset(); _hwndDDF.reset(); diff --git a/src/Updater/main.cpp b/src/Updater/main.cpp index af9e4d73..90607917 100644 --- a/src/Updater/main.cpp +++ b/src/Updater/main.cpp @@ -37,7 +37,9 @@ static bool WaitForMagpieToExit() noexcept { { wil::unique_mutex_nothrow hSingleInstanceMutex; if (hSingleInstanceMutex.try_create(CommonSharedConstants::SINGLE_INSTANCE_MUTEX_NAME)) { - wil::handle_wait(hSingleInstanceMutex.get(), 10000); + if (wil::handle_wait(hSingleInstanceMutex.get(), 10000)) { + hSingleInstanceMutex.ReleaseMutex(); + } } }