-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
[Merged by Bors] - Fix unsound EntityMut::remove_children
. Add EntityMut::world_scope
#6464
Conversation
In #5845, I had added a method to update the world safely: Maybe you could add it? There were some discussion around it, you can find them there: https://github.com/bevyengine/bevy/pull/5845/files |
f1b2de4
to
201a3f9
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.
lgtm
@@ -543,6 +543,12 @@ impl<'w> EntityMut<'w> { | |||
self.world | |||
} | |||
|
|||
/// Gives mutable access to this `EntityMut`'s [`World`] in a temporary scope. |
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.
Might benefit from explaining why you'd want to use it.
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.
It's the only way of safely getting a &mut World
from an EntityMut
without consuming self
. Which sort of speaks for itself?
I'm not sure what to add to the docs that could make that clearer (Aside from being very pedantic) :)
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.
You could discuss update_location here, but that's very gory-internals, and likely to go out of date in dangerous ways. If people care, they can read the code.
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.
I was thinking: someone reading the doc doesn't necessarily see the source code. If they encounter this method, they may ask themselves why its here. But I agree with alice, it's really a minor thing and really depends on internals.
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.
bors r+
`EntityMut::remove_children` does not call `self.update_location()` which is unsound. Verified by adding the following assertion, which fails when running the tests. ```rust let before = self.location(); self.update_location(); assert_eq!(before, self.location()); ``` I also removed incorrect messages like "parent entity is not modified" and the unhelpful "Inserting a bundle in the children entities may change the parent entity's location if they were of the same archetype" which might lead people to think that's the *only* thing that can change the entity's location. Co-authored-by: devil-ira <justthecooldude@gmail.com>
Can you add a change log item for the new |
Build failed: |
EntityMut::remove_children
EntityMut::remove_children
. Add EntityMut::world_scope
bors retry |
#6464) `EntityMut::remove_children` does not call `self.update_location()` which is unsound. Verified by adding the following assertion, which fails when running the tests. ```rust let before = self.location(); self.update_location(); assert_eq!(before, self.location()); ``` I also removed incorrect messages like "parent entity is not modified" and the unhelpful "Inserting a bundle in the children entities may change the parent entity's location if they were of the same archetype" which might lead people to think that's the *only* thing that can change the entity's location. # Changelog Added `EntityMut::world_scope`. Co-authored-by: devil-ira <justthecooldude@gmail.com>
EntityMut::remove_children
. Add EntityMut::world_scope
EntityMut::remove_children
. Add EntityMut::world_scope
bevyengine#6464) `EntityMut::remove_children` does not call `self.update_location()` which is unsound. Verified by adding the following assertion, which fails when running the tests. ```rust let before = self.location(); self.update_location(); assert_eq!(before, self.location()); ``` I also removed incorrect messages like "parent entity is not modified" and the unhelpful "Inserting a bundle in the children entities may change the parent entity's location if they were of the same archetype" which might lead people to think that's the *only* thing that can change the entity's location. # Changelog Added `EntityMut::world_scope`. Co-authored-by: devil-ira <justthecooldude@gmail.com>
EntityMut::remove_children
does not callself.update_location()
which is unsound.Verified by adding the following assertion, which fails when running the tests.
I also removed incorrect messages like "parent entity is not modified" and the unhelpful "Inserting a bundle in the children entities may change the parent entity's location if they were of the same archetype" which might lead people to think that's the only thing that can change the entity's location.
Changelog
Added
EntityMut::world_scope
.