-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix properties being lost when reloading placeholder GDScript instance #24877
Conversation
During reloading in `GDScriptLanguage::reload_all_scripts` a placeholder instance that must remain so is replaced with a new placeholder instance. The state is then restored by calling `ScriptInstance::set` for each property. This does not work if the script is missing the properties due to build/parse failing. The fix for such cases is to call `placeholder_set_fallback` instead of `set` on the script instance. I took this chance to move the `build_failed` flag from `PlaceHolderScriptInstance` to `Script`. That improves the code a lot. I also renamed it to `placeholder_fallback_enabled` which is a much better name (`build_failed` could lead to misunderstandings).
FYI - you removed all reviewers? Not sure if you meant to do that? |
I really think build_failed is more explicit and to the point as a name. |
Tested on my reproduction case - it works! Thank you a lot @neikeq ! |
I think we could keep the name to |
The name For example, in the case of GDScript, what is the difference between |
Thanks! |
Fixes #24280
Supersedes #24707
During reloading in
GDScriptLanguage::reload_all_scripts
a placeholder instance that must remain so is replaced with a new placeholder instance. The state is then restored by callingScriptInstance::set
for each property. This does not work if the script is missing the properties due to build/parse failing.The fix for such cases is to call
placeholder_set_fallback
instead ofset
on the script instance.(Another solution could be to call
Object::set
instead, which already deals with this problem. However, I'm not sure if that could cause any regression or if it would add too much overhead.)The reason the same bug was not happening with C# is because there we don't replace placeholder instances with new placeholder instances during reloading, we just keep the existing one. I'm not familiar enough with the GDScript module to understand why it does not do the same.
I took this chance to move the
build_failed
flag fromPlaceHolderScriptInstance
toScript
. That improves the code a lot. I also renamed it toplaceholder_fallback_enabled
which is a much better name (build_failed
could lead to misunderstandings).