Skip to content

Commit

Permalink
Fix destroy shape race condition (#95)
Browse files Browse the repository at this point in the history
- Fixes #92
  • Loading branch information
Ughuuu authored May 4, 2024
1 parent 8135d01 commit 75a9e9f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/bodies/rapier_collision_object_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ void RapierCollisionObject2D::set_shape(int p_index, RapierShape2D *p_shape) {

Shape &shape = shapes[p_index];

_destroy_shape(shape, p_index);

shape.shape->remove_owner(this);
shape.shape = p_shape;

_destroy_shape(shape, p_index);

p_shape->add_owner(this);

if (!shape.disabled) {
Expand Down Expand Up @@ -97,13 +97,13 @@ void RapierCollisionObject2D::remove_shape(int p_index) {

Shape &shape = shapes[p_index];

shape.shape->remove_owner(this);
shapes.remove_at(p_index);

if (!shape.disabled) {
_destroy_shape(shape, p_index);
}

shape.shape->remove_owner(this);
shapes.remove_at(p_index);

if (space) {
_shapes_changed();
}
Expand Down

0 comments on commit 75a9e9f

Please sign in to comment.