Don't remove entry from ResourceEntities when removing a resource by ID#23716
Merged
alice-i-cecile merged 3 commits intobevyengine:mainfrom Apr 8, 2026
Merged
Don't remove entry from ResourceEntities when removing a resource by ID#23716alice-i-cecile merged 3 commits intobevyengine:mainfrom
ResourceEntities when removing a resource by ID#23716alice-i-cecile merged 3 commits intobevyengine:mainfrom
Conversation
kfc35
approved these changes
Apr 8, 2026
Contributor
kfc35
left a comment
There was a problem hiding this comment.
This issue was mentioned in another PR: #23174 (comment), so this is a great find!
alice-i-cecile
approved these changes
Apr 8, 2026
Contributor
|
With #23616 merged, this just needs to readjust for the fact that |
Remove unused `remove` method and remove dereferences from new `get` calls.
Contributor
Author
|
Yeah, sorry, I knew that conflict would happen. I just didn't expect both PRs to be merged so fast!! I also need to remove the now-unused |
viridia
pushed a commit
to viridia/bevy
that referenced
this pull request
Apr 10, 2026
…y ID (bevyengine#23716) # Objective Make the behavior of `World::remove_resource` and `World::remove_resource_by_id` consistent. Currently, `remove_resource` will leave the entity in the `ResourceEntities` map so that re-initializing the resource keeps the same `Entity`, but `remove_resource_by_id` will remove it from the map. ## Solution Change `remove` to `get` in `remove_resource_by_id`. ## Testing Updated the existing unit test to ensure that re-initializing the resource keeps the same `Entity`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Objective
Make the behavior of
World::remove_resourceandWorld::remove_resource_by_idconsistent. Currently,remove_resourcewill leave the entity in theResourceEntitiesmap so that re-initializing the resource keeps the sameEntity, butremove_resource_by_idwill remove it from the map.Solution
Change
removetogetinremove_resource_by_id.Testing
Updated the existing unit test to ensure that re-initializing the resource keeps the same
Entity.