[3.x] Try loading the path specified in a preload(..) method call with the ResourceLoader if the script code completion cache is not yet available #69362
+2
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #69360
Fixes: #78475
Maybe related to: #35248 (Not sure as I didn't used an external editor, but the issue there sounds very similar)
This fixes the problem that autoloaded nodes could not be loaded because they (or there children) preload other nodes in their script.
This only happened at the start of Godot. When the autoloaded nodes will be resolved, there is no
ScriptCodeCompletionCache
yet.This scenario is also handled above, so we may as well handle it here in the same way.
godot/modules/gdscript/gdscript_parser.cpp
Line 522 in 7cfd984
Why exactly is the
ScriptCodeCompletionCache
not yet resolved?In editor_node:
ProjectSettingsEditor
is instantiated ->EditorAutoloadSettings
-> Autoloaded scenes will be createdScriptEditorPlugin
is instantiated ->ScriptCodeCompletionCache
will be instantiatedANOTHER POSSIBLE FIX
Initialize the
ScriptCodeCompletionCache
(ScriptCodeCompletionCache::get_singleton()
) before resolving the autoloaded scenes.Then the
ScriptCodeCompletionCache
cache can be reused. (Order needs be changed ineditor_node
)Moving down the
ProjectSettingsEditor
in the instantiation order (afterScriptEditorPlugin
) does work and everything looks normal. And theScriptCodeCompletionCache
is created before the autoloaded nodes are created. But this is a much more risky change.Note: This bug does not happen in Godot 4.0