Make discord code more thread safe

This commit is contained in:
Benau 2021-03-11 10:44:24 +08:00
parent f2cc6559e6
commit da05d1e905
2 changed files with 8 additions and 7 deletions

View File

@ -78,6 +78,12 @@ void RichPresence::terminate()
#else
#define UNCLEAN m_socket != -1
#endif
if(m_thread != nullptr && STKProcess::getType() == PT_MAIN)
{
m_thread->join();
delete m_thread;
m_thread = nullptr;
}
if (m_connected || UNCLEAN)
{
if (UNCLEAN && !m_connected)
@ -92,12 +98,6 @@ void RichPresence::terminate()
m_connected = false;
m_ready = false;
}
if(m_thread != nullptr && STKProcess::getType() == PT_MAIN)
{
m_thread->join();
delete m_thread;
m_thread = nullptr;
}
#endif // DISABLE_RPC
}

View File

@ -1,3 +1,4 @@
#include <atomic>
#ifdef WIN32
#include <namedpipeapi.h>
#endif
@ -21,7 +22,7 @@ namespace RichPresenceNS
{
private:
bool m_connected;
bool m_ready;
std::atomic_bool m_ready;
time_t m_last;
#ifdef WIN32
HANDLE m_socket;