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

Fix² behavior of ResourceFormatLoader CACHE_MODE_REPLACE #87008

Merged
merged 1 commit into from Feb 13, 2024

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Jan 9, 2024

Same as #84167, but does not introduce #86187

When a resource is already loaded, CACHE_MODE_REPLACE will use copy_from() to replace the data in the loaded instances (in the previous version of this PR, the old instances were invalidated and made local).

Fixes #81498

@KoBeWi KoBeWi added this to the 4.3 milestone Jan 9, 2024
@KoBeWi KoBeWi requested a review from a team as a code owner January 9, 2024 14:51
Comment on lines 343 to 350
if (load_task.cache_mode == ResourceFormatLoader::CACHE_MODE_REPLACE) {
Ref<Resource> res = ResourceCache::get_ref(load_task.local_path);
if (res.is_valid() && res != load_task.resource) {
// If resource is already loaded, only replace its data, to avoid existing invalidating instances.
res->copy_from(load_task.resource);
load_task.resource = res;
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is added by this PR and it's the only difference from the previous one.

Copy link
Member

@RandomShaper RandomShaper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit hard to assess all the possible outcomes, but looks sensible.

@akien-mga akien-mga merged commit dc99c8d into godotengine:master Feb 13, 2024
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@KoBeWi KoBeWi deleted the cache_mode_replace_fixes² branch February 13, 2024 23:07
RandomShaper added a commit to RandomShaper/godot that referenced this pull request Feb 22, 2024
- Unify documentation, hoping to clear misconcepctions about about propagation of the cache mode across dependant loads.
- Clarify in docs that `CACHE_MODE_REPLACE` now also works on the main resource (from godotengine#87008).
- Add two recursive modes, counterparts of `CACHE_MODE_REPLACE` and `CACHE_MODE_IGNORE`, since it seems some need them (see godotengine#59669, godotengine#82830).
- Let resources, even loaded with one of the ignore-cache modes, get a path, which is useful for tools.
RandomShaper added a commit to RandomShaper/godot that referenced this pull request Feb 22, 2024
- Unify documentation, hoping to clear misconcepctions about about propagation of the cache mode across dependant loads.
- Clarify in docs that `CACHE_MODE_REPLACE` now also works on the main resource (from godotengine#87008).
- Add two recursive modes, counterparts of `CACHE_MODE_REPLACE` and `CACHE_MODE_IGNORE`, since it seems some need them (see godotengine#59669, godotengine#82830).
- Let resources, even loaded with one of the ignore-cache modes, get a path, which is useful for tools.
RandomShaper added a commit to RandomShaper/godot that referenced this pull request Feb 26, 2024
- Unify documentation, hoping to clear misconcepctions about about propagation of the cache mode across dependant loads.
- Clarify in docs that `CACHE_MODE_REPLACE` now also works on the main resource (from godotengine#87008).
- Add two recursive modes, counterparts of `CACHE_MODE_REPLACE` and `CACHE_MODE_IGNORE`, since it seems some need them (see godotengine#59669, godotengine#82830).
- Let resources, even loaded with one of the ignore-cache modes, get a path, which is useful for tools.
RandomShaper added a commit to RandomShaper/godot that referenced this pull request Feb 26, 2024
- Unify documentation, hoping to clear misconcepctions about about propagation of the cache mode across dependant loads.
- Clarify in docs that `CACHE_MODE_REPLACE` now also works on the main resource (from godotengine#87008).
- Add two recursive modes, counterparts of `CACHE_MODE_REPLACE` and `CACHE_MODE_IGNORE`, since it seems some need them (see godotengine#59669, godotengine#82830).
- Let resources, even loaded with one of the ignore-cache modes, get a path, which is useful for tools.
RandomShaper added a commit to RandomShaper/godot that referenced this pull request Feb 26, 2024
- Unify documentation, hoping to clear misconcepctions about about propagation of the cache mode across dependant loads.
- Clarify in docs that `CACHE_MODE_REPLACE` now also works on the main resource (from godotengine#87008).
- Add two recursive modes, counterparts of `CACHE_MODE_REPLACE` and `CACHE_MODE_IGNORE`, since it seems some need them (see godotengine#59669, godotengine#82830).
- Let resources, even loaded with one of the ignore-cache modes, get a path, which is useful for tools.
RandomShaper added a commit to RandomShaper/godot that referenced this pull request Feb 26, 2024
- Unify documentation, hoping to clear misconcepctions about about propagation of the cache mode across dependant loads.
- Clarify in docs that `CACHE_MODE_REPLACE` now also works on the main resource (from godotengine#87008).
- Add two recursive modes, counterparts of `CACHE_MODE_REPLACE` and `CACHE_MODE_IGNORE`, since it seems some need them (see godotengine#59669, godotengine#82830).
- Let resources, even loaded with one of the ignore-cache modes, get a path, which is useful for tools.
sambler pushed a commit to sambler/godot that referenced this pull request Apr 6, 2024
- Unify documentation, hoping to clear misconcepctions about about propagation of the cache mode across dependant loads.
- Clarify in docs that `CACHE_MODE_REPLACE` now also works on the main resource (from godotengine#87008).
- Add two recursive modes, counterparts of `CACHE_MODE_REPLACE` and `CACHE_MODE_IGNORE`, since it seems some need them (see godotengine#59669, godotengine#82830).
- Let resources, even loaded with one of the ignore-cache modes, get a path, which is useful for tools.
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.

Built-in script of preloaded scene requires editor restart to become tool
3 participants