Ensure cyclic dependencies between scripts are broken at exit
This commit is contained in:
parent
a0969662cd
commit
8e64969184
|
@ -2244,6 +2244,22 @@ GDScriptLanguage::~GDScriptLanguage() {
|
|||
if (_call_stack) {
|
||||
memdelete_arr(_call_stack);
|
||||
}
|
||||
|
||||
// Clear dependencies between scripts, to ensure cyclic references are broken (to avoid leaks at exit).
|
||||
while (script_list.first()) {
|
||||
GDScript *script = script_list.first()->self();
|
||||
for (Map<StringName, GDScriptFunction *>::Element *E = script->member_functions.front(); E; E = E->next()) {
|
||||
GDScriptFunction *func = E->get();
|
||||
for (int i = 0; i < func->argument_types.size(); i++) {
|
||||
func->argument_types.write[i].script_type_ref = Ref<Script>();
|
||||
}
|
||||
func->return_type.script_type_ref = Ref<Script>();
|
||||
}
|
||||
for (Map<StringName, GDScript::MemberInfo>::Element *E = script->member_indices.front(); E; E = E->next()) {
|
||||
E->get().data_type.script_type_ref = Ref<Script>();
|
||||
}
|
||||
}
|
||||
|
||||
singleton = NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue