Skip to content

Commit

Permalink
fix: 修复忘记释放某些 mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
Blinue committed Jun 5, 2024
1 parent 8028dcd commit 238f66e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Magpie.Core/ExclModeHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/Magpie.Core/ScalingWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ LRESULT ScalingWindow::_MessageHandler(UINT msg, WPARAM wParam, LPARAM lParam) n
}
case WM_DESTROY:
{
_exclModeMutex.ReleaseMutex();
_exclModeMutex.reset();

_hwndDDF.reset();
Expand Down
4 changes: 3 additions & 1 deletion src/Updater/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

Expand Down

0 comments on commit 238f66e

Please sign in to comment.