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

1
.gitignore vendored
View File

@@ -1,6 +1,7 @@
# Objects. # Objects.
.scons-cache/ .scons-cache/
*.os *.os
*.o
# SConstruct # SConstruct
.sconf_temp .sconf_temp

View File

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

View File

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