diff options
author | kobewi <kobewi4e@gmail.com> | 2022-09-16 17:42:06 +0200 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2022-12-02 00:20:11 +0100 |
commit | e9a3e49086d466e4beb3d8458149b58f5f6115bd (patch) | |
tree | a447d501705a8c27f8aae18c94281db10e7f4957 /modules/gdscript/gdscript.cpp | |
parent | cd491c6e47bb41ccf596189676c0c5d4a72226cc (diff) | |
download | redot-engine-e9a3e49086d466e4beb3d8458149b58f5f6115bd.tar.gz |
Cleanup function state connections when destroying instance
Co-authored-by: Adam Scott <ascott.ca@gmail.com>
Diffstat (limited to 'modules/gdscript/gdscript.cpp')
-rw-r--r-- | modules/gdscript/gdscript.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 60230257e0..9eb65695a2 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1483,7 +1483,12 @@ GDScript::~GDScript() { // Order matters since clearing the stack may already cause // the GDScriptFunctionState to be destroyed and thus removed from the list. pending_func_states.remove(E); - E->self()->_clear_stack(); + GDScriptFunctionState *state = E->self(); + ObjectID state_id = state->get_instance_id(); + state->_clear_connections(); + if (ObjectDB::get_instance(state_id)) { + state->_clear_stack(); + } } } @@ -1926,7 +1931,12 @@ GDScriptInstance::~GDScriptInstance() { // Order matters since clearing the stack may already cause // the GDSCriptFunctionState to be destroyed and thus removed from the list. pending_func_states.remove(E); - E->self()->_clear_stack(); + GDScriptFunctionState *state = E->self(); + ObjectID state_id = state->get_instance_id(); + state->_clear_connections(); + if (ObjectDB::get_instance(state_id)) { + state->_clear_stack(); + } } if (script.is_valid() && owner) { |