Skip to content

Commit

Permalink
fix GDRESettings memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitalita committed Jan 13, 2024
1 parent 0bae1de commit 23e1c33
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void gdsdecomp_init_callback() {
editor->add_child(memnew(GodotREEditor(editor)));
};
#endif
static GDRESettings *gdre_singleton = nullptr;

void initialize_gdsdecomp_module(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
Expand Down Expand Up @@ -52,8 +53,8 @@ void initialize_gdsdecomp_module(ModuleInitializationLevel p_level) {
ClassDB::register_class<NewPackDialog>();
ClassDB::register_class<ScriptCompDialog>();
ClassDB::register_class<ScriptDecompDialog>();

Engine::get_singleton()->add_singleton(Engine::Singleton("GDRESettings", memnew(GDRESettings)));
gdre_singleton = memnew(GDRESettings);
Engine::get_singleton()->add_singleton(Engine::Singleton("GDRESettings", GDRESettings::get_singleton()));

#ifdef TOOLS_ENABLED
EditorNode::add_init_callback(&gdsdecomp_init_callback);
Expand All @@ -62,4 +63,8 @@ void initialize_gdsdecomp_module(ModuleInitializationLevel p_level) {

void uninitialize_gdsdecomp_module(ModuleInitializationLevel p_level) {
//NOP
if (gdre_singleton) {
memdelete(gdre_singleton);
gdre_singleton = nullptr;
}
}

0 comments on commit 23e1c33

Please sign in to comment.