Skip to content
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

[Core] Fix ResourceLoader.load cache with relative paths #90038

Merged
merged 1 commit into from
Apr 4, 2024

Conversation

AThousandShips
Copy link
Member

@AThousandShips AThousandShips commented Mar 30, 2024

Paths were not simplified meaning that res://foo.bar was treated differently from ./foo.bar and similar

This matches how paths with the res:// prefix are handled, which are simplified as part of the localize_path

The documentation for load states that these paths are not loaded, that's something to discuss and evaluate in a separate PR though, as this is is specific to ResourceLoader.load and just happens to affect this part as well, and loading relative paths in the resource loader is supported (no claim in the documentation to the contrary)

There are also some potential issues with how threaded loading handles paths that I will look into separately, as it might be more consequential, as opposed to this which is a straightforward fix

Paths were not simplified meaning that `res://foo.bar` was treated
differently from `./foo.bar` and similar
@AThousandShips AThousandShips added bug topic:core cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release labels Mar 30, 2024
@AThousandShips AThousandShips added this to the 4.3 milestone Mar 30, 2024
@AThousandShips AThousandShips requested a review from a team as a code owner March 30, 2024 11:54
@ajreckof
Copy link
Member

ajreckof commented Apr 1, 2024

I see how this can fix the issue but I'm wondering if it won't have problems in more niche cases. In particular I'm wondering wether should not append the "res://" in case it is relative before anything else and handle it exactly the same so that there is exaclty no difference between "res://SomeScript.gd" and "./SomeScript". Maybe there is an actual downside of doing it like that that I didn't see.

For clarification this is what I mens by apennding "res://" first : https://github.com/godotengine/godot/compare/master...ajreckof:Fix-ResourceLoader.load-cache-with-relative-paths?expand=1

@AThousandShips
Copy link
Member Author

This is the least disruptive solution, all it affects is the caching, your suggestion wouldn't change anything, see how the method works:

String ProjectSettings::localize_path(const String &p_path) const {
String path = p_path.simplify_path();
if (resource_path.is_empty() || (path.is_absolute_path() && !path.begins_with(resource_path))) {
return path;
}

The UID won't fetch anything as it won't be a UID

@akien-mga akien-mga merged commit c8088c1 into godotengine:master Apr 4, 2024
16 checks passed
@AThousandShips AThousandShips deleted the load_path branch April 4, 2024 12:46
@akien-mga
Copy link
Member

Thanks!

@AThousandShips
Copy link
Member Author

Thank you!

@akien-mga
Copy link
Member

Cherry-picked for 4.2.2.

@akien-mga akien-mga removed the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants