-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
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 updating cached singletons when reloading GDScripts #85373
Fix updating cached singletons when reloading GDScripts #85373
Conversation
I simplified this commit. Now everything happens in Right now there are only two cases when a Btw 4.2 will be the first release with hot reload support for GDExtension. 4.2 RC2 isn't the last release candidate, is it? |
A release candidate should always expect to be the last, otherwise it's not a release candidate ;) This doesn't seem critical (doesn't prevent shipping games, only impacts hot reload during extension development), so it doesn't seem urgent to merge mere days before the stable release. Like other bug fixes, it can be merged afterwards and cherry-picked for 4.2.1. |
I'd like to offer a counterpoint. Hot Reloading for GDExtension seems like it will be a very popular feature for 4.2, which means making sure its bug free and ready to be used is probably important. Although, I'm not sure how annoying this bug is, so YMMV. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This fixes the issue with the MRP from #85004 in my testing.
The code makes sense to me based on looking at the references from the PR description, but it should probably be reviewed by someone on the GDScript team.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me. Refreshing the pointers to the singletons are necessary if the extensions are reloaded.
Thanks! |
Cherry-picked for 4.2.1. |
Fixes #85004
Since
GDScriptLanguage::reload_all_scripts()
is always called when theGDExtension
reload is completed, I decided to update the singleton cache there.I used the original singleton caching code, added a key existence check, and just overwrite the values.
Without
globals.has(E.name)
singletons that were registered viaGDScript
itself or for exampleGDScriptLanguageProtocol
can be added to the cache after theGDExtension
reload and used as the rest of the singletons inGDScript
.#52162 could be fixed if calling
reload_all_scripts
somewhere after loading the editor (there?) and removeglobals.has(E.name)
. I tried updating scripts inEngine::add_singleton
, but it is advisable to do it deferred, andEngine
is a regular class that cannot call methods viacallable_mp
(although it was possible to add a static method and a static boolean variable to prevent multiple calls in one frame). This can be tested in a separate PR, but I'm not really interested in it.It would be cool to merge this before the 4.2 release.