mirror of
https://github.com/yuzu-emu/discord-rpc.git
synced 2024-12-22 19:25:40 +00:00
Dynamically create IoThread... (#179)
So that it doesn't get deleted before Discord is destroyed.
This commit is contained in:
parent
cac0362377
commit
ba9fe00c4d
|
@ -118,7 +118,7 @@ public:
|
||||||
void Notify() {}
|
void Notify() {}
|
||||||
};
|
};
|
||||||
#endif // DISCORD_DISABLE_IO_THREAD
|
#endif // DISCORD_DISABLE_IO_THREAD
|
||||||
static IoThreadHolder IoThread;
|
static IoThreadHolder* IoThread{nullptr};
|
||||||
|
|
||||||
static void UpdateReconnectTime()
|
static void UpdateReconnectTime()
|
||||||
{
|
{
|
||||||
|
@ -237,7 +237,9 @@ static void Discord_UpdateConnection(void)
|
||||||
|
|
||||||
static void SignalIOActivity()
|
static void SignalIOActivity()
|
||||||
{
|
{
|
||||||
IoThread.Notify();
|
if (IoThread != nullptr) {
|
||||||
|
IoThread->Notify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool RegisterForEvent(const char* evtName)
|
static bool RegisterForEvent(const char* evtName)
|
||||||
|
@ -271,6 +273,11 @@ extern "C" DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
|
||||||
int autoRegister,
|
int autoRegister,
|
||||||
const char* optionalSteamId)
|
const char* optionalSteamId)
|
||||||
{
|
{
|
||||||
|
IoThread = new (std::nothrow) IoThreadHolder();
|
||||||
|
if (IoThread == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (autoRegister) {
|
if (autoRegister) {
|
||||||
if (optionalSteamId && optionalSteamId[0]) {
|
if (optionalSteamId && optionalSteamId[0]) {
|
||||||
Discord_RegisterSteamGame(applicationId, optionalSteamId);
|
Discord_RegisterSteamGame(applicationId, optionalSteamId);
|
||||||
|
@ -335,7 +342,7 @@ extern "C" DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
|
||||||
UpdateReconnectTime();
|
UpdateReconnectTime();
|
||||||
};
|
};
|
||||||
|
|
||||||
IoThread.Start();
|
IoThread->Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" DISCORD_EXPORT void Discord_Shutdown(void)
|
extern "C" DISCORD_EXPORT void Discord_Shutdown(void)
|
||||||
|
@ -346,7 +353,12 @@ extern "C" DISCORD_EXPORT void Discord_Shutdown(void)
|
||||||
Connection->onConnect = nullptr;
|
Connection->onConnect = nullptr;
|
||||||
Connection->onDisconnect = nullptr;
|
Connection->onDisconnect = nullptr;
|
||||||
Handlers = {};
|
Handlers = {};
|
||||||
IoThread.Stop();
|
if (IoThread != nullptr) {
|
||||||
|
IoThread->Stop();
|
||||||
|
delete IoThread;
|
||||||
|
IoThread = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
RpcConnection::Destroy(Connection);
|
RpcConnection::Destroy(Connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue