Add cyclic dependencies support for scenes's scripts#71004
Add cyclic dependencies support for scenes's scripts#71004adamscott wants to merge 1 commit intogodotengine:masterfrom
Conversation
|
|
||
| #ifdef MODULE_GDSCRIPT_ENABLED | ||
| // GDScript has a way to load cyclic dependencies | ||
| if (res.is_null() && ResourceLoader::get_resource_type(path) == "GDScript") { |
There was a problem hiding this comment.
I know @reduz won't be pleased with this, but I wonder if there's another way to do this? GDScript is pretty much the only resource (with the workaround found for packed scenes in GDScriptCache) that supports cyclic resources.
ResourceLoader::load(path, type) returns a null Variant when it's already loading that resource, instead of returning the resource currently loaded. But it cannot do that because that resource doesn't exist, hence that GDScript check.
|
This really needs an input from @reduz. Including module code in |
|
@akien-mga told me that this core hack is a no-go. Closing. |
|
To be clear, I said:
I do believe that it should be possible to move this to GDScript code somehow. Can't it be done here? Ref<Resource> ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
if (r_error) {
*r_error = ERR_FILE_CANT_OPEN;
}
Error err;
Ref<GDScript> scr = GDScriptCache::get_full_script(p_path, err, "", p_cache_mode == CACHE_MODE_IGNORE);
// TODO: Reintroduce binary and encrypted scripts.
if (scr.is_null()) {
// Don't fail loading because of parsing error.
scr.instantiate();
}
if (r_error) {
*r_error = OK;
}
return scr;
}Might require more work to figure out if it's failing loading due to parsing errors or due to cyclic dependencies (maybe this can be passed via |
No. :( Considering that
Otherwise, if it was called, |
Enables loading scenes scripts with cyclic dependencies.
Fixes #70985