Common/Timer: Fix closing invalid handle on Win32

Only is an issue if you have a debugger attached and the exception
enabled.
This commit is contained in:
Connor McLaughlin 2022-04-16 12:43:59 +10:00 committed by refractionpcsx2
parent eb60e9aa9b
commit b913d39a50
1 changed files with 9 additions and 2 deletions

View File

@ -187,13 +187,20 @@ namespace Common
ThreadCPUTimer::~ThreadCPUTimer()
{
#ifdef _WIN32
CloseHandle(reinterpret_cast<HANDLE>(m_thread_handle));
if (m_thread_handle)
CloseHandle(reinterpret_cast<HANDLE>(m_thread_handle));
#endif
}
ThreadCPUTimer& ThreadCPUTimer::operator=(ThreadCPUTimer&& move)
{
std::swap(m_thread_handle, move.m_thread_handle);
#ifdef _WIN32
if (m_thread_handle)
CloseHandle(reinterpret_cast<HANDLE>(m_thread_handle));
#endif
m_thread_handle = move.m_thread_handle;
move.m_thread_handle = nullptr;
return *this;
}