Fix autoloaded scene loses their built-in script when upgrading to 4.4 #103439
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.
I'm not 100% certain why the modifications from #102636 afftected this issue but I think the issue is caused because with the modifications, the Player script in the MVP is now valid at the moment of the upgrade, causing the autoload script (BulletManager) to load while loading the Player script during the upgrade process.
In the
GDScriptCache::get_shallow_script
, the BulletManager script resource (which is an embedded script into the scene) is created but without it's scene unique id.That causes the save of the bullet_manager.tscn to create a new embedded script with a new id when resaving it in the upgrade process.
I fixed the issue by using the
ResourceFormatLoader::CACHE_MODE_REPLACE
cache mode to theResourceLoader::load
inUIDUpgradeTool::finish_upgrade
:Ref<Resource> res = ResourceLoader::load(file_path, "", ResourceFormatLoader::CACHE_MODE_REPLACE);
That forces the scene and the script to be reloaded completely from the disk during the upgrade progress.