From dcffedc18e1227af27b9d008b034c29dfd8825a5 Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Fri, 6 May 2022 18:52:26 +0000 Subject: [PATCH] Apply buffers in `ParamSet` (#4677) # Objective - Fix https://github.com/bevyengine/bevy/issues/4676 ## Solution - Fixes https://github.com/bevyengine/bevy/issues/4676 - I have no reason to think this isn't sound, but `ParamSet` is a bit spooky --- crates/bevy_ecs/macros/src/lib.rs | 4 ++++ crates/bevy_ecs/src/system/mod.rs | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/bevy_ecs/macros/src/lib.rs b/crates/bevy_ecs/macros/src/lib.rs index f67ce35bbb997c..0f57f448a18e7c 100644 --- a/crates/bevy_ecs/macros/src/lib.rs +++ b/crates/bevy_ecs/macros/src/lib.rs @@ -250,6 +250,10 @@ pub fn impl_param_set(_input: TokenStream) -> TokenStream { #param.new_archetype(archetype, system_meta); )* } + + fn apply(&mut self, world: &mut World) { + self.0.apply(world) + } } diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 52d8b0a12d6f93..541cd674be935b 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -103,7 +103,7 @@ mod tests { query::{Added, Changed, Or, With, Without}, schedule::{Schedule, Stage, SystemStage}, system::{ - IntoExclusiveSystem, IntoSystem, Local, NonSend, NonSendMut, ParamSet, Query, + Commands, IntoExclusiveSystem, IntoSystem, Local, NonSend, NonSendMut, ParamSet, Query, RemovedComponents, Res, ResMut, System, SystemState, }, world::{FromWorld, World}, @@ -906,4 +906,23 @@ mod tests { expected_ids ); } + + #[test] + fn commands_param_set() { + // Regression test for #4676 + let mut world = World::new(); + let entity = world.spawn().id(); + + run_system( + &mut world, + move |mut commands_set: ParamSet<(Commands, Commands)>| { + commands_set.p0().entity(entity).insert(A); + commands_set.p1().entity(entity).insert(B); + }, + ); + + let entity = world.entity(entity); + assert!(entity.contains::()); + assert!(entity.contains::()); + } }