[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
Open
Maran23 wants to merge 1 commit intogodotengine:3.xfrom
Conversation
a8491a1 to
c665c77
Compare
…ResourceLoader if the script code completion cache is not yet available This fixes the problem that autoloaded nodes could not be loaded because they (or there children) preload other nodes in their script. This was only happening on the start of Godot, as when the autoloaded nodes are resolved there is no code completion cache yet.
c665c77 to
976b1dd
Compare
akien-mga
reviewed
Jun 30, 2023
Comment on lines
+530
to
+531
| } else { | ||
| res = ResourceLoader::load(path); |
Member
There was a problem hiding this comment.
I'm not familiar with this code but I feel like the comment in the !validating branch:
//this can be too slow for just validating code
actually explains why this else branch does not do a load, which is expensive.
CC @vnen @adamscott (note: 3.x code)
Contributor
Author
There was a problem hiding this comment.
Same thought, but better then failing. Since this only affects autoloaded Nodes that uses preload, it seems okay to me
Valla-Chan
added a commit
to Valla-Chan/Godot-3.5.1-Ghodost
that referenced
this pull request
Jan 20, 2024
(Try loading the path specified in a preload(..) method call with the ResourceLoader if the script code completion cache is not yet available)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
ScriptCodeCompletionCacheyet.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
ScriptCodeCompletionCachenot yet resolved?In editor_node:
ProjectSettingsEditoris instantiated ->EditorAutoloadSettings-> Autoloaded scenes will be createdScriptEditorPluginis instantiated ->ScriptCodeCompletionCachewill be instantiatedANOTHER POSSIBLE FIX
Initialize the
ScriptCodeCompletionCache(ScriptCodeCompletionCache::get_singleton()) before resolving the autoloaded scenes.Then the
ScriptCodeCompletionCachecache can be reused. (Order needs be changed ineditor_node)Moving down the
ProjectSettingsEditorin the instantiation order (afterScriptEditorPlugin) does work and everything looks normal. And theScriptCodeCompletionCacheis 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