From e9a3e49086d466e4beb3d8458149b58f5f6115bd Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 16 Sep 2022 17:42:06 +0200 Subject: Cleanup function state connections when destroying instance Co-authored-by: Adam Scott --- modules/gdscript/gdscript_function.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules/gdscript/gdscript_function.cpp') diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index 24a614b1ad..d167af576e 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -296,6 +296,15 @@ void GDScriptFunctionState::_clear_stack() { } } +void GDScriptFunctionState::_clear_connections() { + List conns; + get_signals_connected_to_this(&conns); + + for (Object::Connection &c : conns) { + c.signal.disconnect(c.callable); + } +} + void GDScriptFunctionState::_bind_methods() { ClassDB::bind_method(D_METHOD("resume", "arg"), &GDScriptFunctionState::resume, DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDScriptFunctionState::is_valid, DEFVAL(false)); -- cgit v1.2.3