-
-
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 sub-resource IDs resetting when preloaded #72257
Fix sub-resource IDs resetting when preloaded #72257
Conversation
Needs rebase to pass CI, I fixed the GDScript test error. |
28682c1
to
86049dc
Compare
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.
Tentatively approving to keep track of it as high priority :) But still needs @reduz to check it.
The problem is that, in many cases, we use CACHE_IGNORE to convert resources on background (on the exporter, as an example) and this change will break the ones currently loaded and edited. I think the right fix is a bit simpler here, just change this code: if (do_assign && cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE) {
res->set_path(path, cache_mode == ResourceFormatLoader::CACHE_MODE_REPLACE);
res->set_scene_unique_id(id);
} by if (do_assign && cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE) {
res->set_path(path, cache_mode == ResourceFormatLoader::CACHE_MODE_REPLACE);
}
res->set_scene_unique_id(id); This way, when the resource is re-saved it will keep the unique ID, but you don't necessarily kill the existing resource when using the CACHE_IGNORE mode. |
After further discussion, it appears that what we need here is to separate the resource cache and the subresource cache modes in the ResourceLoader::load function. I will work on a PR for this soon. |
After some investigation, the original issue is caused by this line: godot/modules/gdscript/gdscript_cache.cpp Line 367 in 0a9e6e4
Resource loaded with CACHE_MODE_IGNORE takes over a path and causes id reset. The solution mentioned in the above comment would fix it, but I think this is not really a correct behavior, idk. |
Closing. This is wrong solution and the actual issue was identified to be different. |
Reopening, as fixing the internal ids is high-priority matter and this works as a temporary fix. |
e373536
to
2a2d96f
Compare
2a2d96f
to
095c805
Compare
Thanks! |
You mentioned that this was probably not a "correct" fix because it breaks something else. What is this other thing that it breaks, out of curiosity? |
That was before I updated the PR. It used to set path for resources that ignore cache (i.e. they are supposed to be temporary). Now it only sets ID, which shouldn't break anything. |
Probably fixes #62258, idk what the issue is about at this point
I had a case in my project where I had a scene A preloading scene B. If I opened A first and then opened B, all B's sub-resource IDs would reset and the built-in script would show as
[unsaved][*]
. It might be the clue of all sub-resource issues reported in the issue.The fix I did is not probably correct (the code seems to have been like this for a very long time, so changing it might have some unwanted side-effects), but it fixes the issue.
EDIT:
I came upon this comment
#71171 (comment)
which basically confirms that it isn't the right fix. But if the cache is ignored, loading the same resource again should replace the resource from ignored load (to make sure it has a path this time).