You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Fix crash when extending non-existing GDScript file
Fixes #21682 with a partial revert of #21411. The ~Ref() destructor (from 'scriptres') already takes care of freeing the 'script' resource.
This commit is contained in:
@@ -2112,23 +2112,14 @@ RES ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_ori
|
|||||||
script->set_script_path(p_original_path); // script needs this.
|
script->set_script_path(p_original_path); // script needs this.
|
||||||
script->set_path(p_original_path);
|
script->set_path(p_original_path);
|
||||||
Error err = script->load_byte_code(p_path);
|
Error err = script->load_byte_code(p_path);
|
||||||
|
|
||||||
if (err != OK) {
|
|
||||||
memdelete(script);
|
|
||||||
ERR_FAIL_COND_V(err != OK, RES());
|
ERR_FAIL_COND_V(err != OK, RES());
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Error err = script->load_source_code(p_path);
|
Error err = script->load_source_code(p_path);
|
||||||
|
|
||||||
if (err != OK) {
|
|
||||||
memdelete(script);
|
|
||||||
ERR_FAIL_COND_V(err != OK, RES());
|
ERR_FAIL_COND_V(err != OK, RES());
|
||||||
}
|
|
||||||
|
|
||||||
script->set_script_path(p_original_path); // script needs this.
|
script->set_script_path(p_original_path); // script needs this.
|
||||||
script->set_path(p_original_path);
|
script->set_path(p_original_path);
|
||||||
//script->set_name(p_path.get_file());
|
|
||||||
|
|
||||||
script->reload();
|
script->reload();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user