mirror of
https://github.com/godotengine/godot
synced 2024-09-05 07:18:49 +00:00
Ensure cyclic dependencies between scripts are broken at exit
This commit is contained in:
parent
95828161d4
commit
e25f5e791e
|
@ -1053,7 +1053,9 @@ GDScript::~GDScript() {
|
||||||
memdelete(E->get());
|
memdelete(E->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptCache::remove_script(get_path());
|
if (GDScriptCache::singleton) { // Cache may have been already destroyed at engine shutdown.
|
||||||
|
GDScriptCache::remove_script(get_path());
|
||||||
|
}
|
||||||
|
|
||||||
_save_orphaned_subclasses();
|
_save_orphaned_subclasses();
|
||||||
|
|
||||||
|
@ -2035,7 +2037,23 @@ GDScriptLanguage::~GDScriptLanguage() {
|
||||||
if (_call_stack) {
|
if (_call_stack) {
|
||||||
memdelete_arr(_call_stack);
|
memdelete_arr(_call_stack);
|
||||||
}
|
}
|
||||||
singleton = nullptr;
|
|
||||||
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptLanguage::add_orphan_subclass(const String &p_qualified_name, const ObjectID &p_subclass) {
|
void GDScriptLanguage::add_orphan_subclass(const String &p_qualified_name, const ObjectID &p_subclass) {
|
||||||
|
|
Loading…
Reference in a new issue