fixed a random crash and stabilized the plugin in general

This commit is contained in:
2024-02-27 13:01:26 +01:00
parent 1b56b8c8df
commit 605080d7ff
10 changed files with 6 additions and 2 deletions

View File

@@ -87,15 +87,17 @@ SET_GET(is_public_party, activity.GetParty().SetPrivacy(static_cast<discord::Act
DiscordSDK::DiscordSDK()
{
ERR_FAIL_COND(singleton != nullptr);
singleton = this;
}
DiscordSDK::~DiscordSDK()
{
singleton = nullptr;
app_id = 0;
delete core; // couldn't use destructor because it would not compile on linux
core = nullptr;
ERR_FAIL_COND(singleton != this);
singleton = nullptr;
}
DiscordSDK *DiscordSDK::get_singleton()

View File

@@ -28,6 +28,7 @@ void uninitialize_discordsdk_module(ModuleInitializationLevel p_level)
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE)
{
Engine::get_singleton()->unregister_singleton("DiscordSDK");
memdelete(discordsdk);
}
}