-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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 saving .tres file with Dictionary/Array containing Resources does not work #57077
Conversation
d02cacb
to
0c151e1
Compare
f4f5e4d
to
f5b05f4
Compare
I will give it a check soon. From what I remember this checked whether resources that were part of sub-resources forced the main one to be saved. |
Nearly right. With my PR the code is more aligned to the actual saving algorithm. While the saving algorithm will also save all sub resources, so e.g. an Array in a |
Okay sorry it took so long, I understand this bug well now as this is very old code. I am not entirely sure at this point whether we should even keep this code and instead now iterate through all loaded resources, check that they were edited and simply save them. I will discuss this a bit with other contributors and get back. |
No problem. I had the same thought. It is probably better to do that when saving. This will simplify the code since only location does the check and saving now - and it will probably also increase the performance a bit. |
f5b05f4
to
10646b0
Compare
… not work The check, if a resource should be saved by checking whether it or it's subresources have been edited now takes arrays and dictionaries into account.
10646b0
to
317b6e1
Compare
I updated this PR and it is now ready for review. I have written my results and findings in the description. |
Btw. the CI error does not look like something caused by my changes (status code 503). Can someone retrigger the JavaScript Build? I think I can't. |
Done (and it indeed succeeded now). |
I attempted an even simpler version of this in #62318 which should solve this problem too. |
Superseded by #62318. Thanks for the contribution nevertheless! |
NOTE: Probably superseded by #62318
Fixes #55885
After some discussion (see comments) and thinking I came to this solution.
The check, if a resource should be saved by checking whether it or its sub-resources have been edited now takes arrays and dictionaries into account.
I also tried changing the logic in the saving done by the
ResourceFormatSaverTextInstance
(resource_format_text.cpp
), but found some problems/insecurities doing so:PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT
and
res->get_path().is_resource_file()
.editor_node.cpp
is only calling the save method ofResourceFormatSaverText
. If not, then other subclasses of theResourceFormatSaver
needs to be adjusted as well (e.g.ResourceFormatSaverBinaryInstance
, logic in here looks very similar).Example: A.tres
Now if we were to save only the edited part, we would save the second array because the string in it was edited, and lose the first array and the file will be corrupt as a result.
So if we want to remove the logic in
editor_node.cpp
and let theresource_format_text.cpp
do the whole job, it needs to be refactored to save the whole resource when at least one subresource was edited (and of course the other two points need to be clarified).