From c836691d027cd74a882f3829ff4937778f090e7c Mon Sep 17 00:00:00 2001 From: Edgar Geier Date: Sun, 23 Jul 2023 16:16:21 +0200 Subject: [PATCH 1/3] Fix `ambiguous_with` breaking run conditions --- crates/bevy_ecs/src/schedule/schedule.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 701e13ff4578f..26dec8af89279 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -1113,7 +1113,7 @@ impl ScheduleGraph { let sys_count = self.systems.len(); let set_with_conditions_count = hg_set_ids.len(); - let node_count = self.systems.len() + self.system_sets.len(); + let hg_node_count = self.hierarchy.graph.node_count(); // get the number of dependencies and the immediate dependents of each system // (needed by multi-threaded executor to run systems in the correct order) @@ -1145,7 +1145,7 @@ impl ScheduleGraph { let bitset = &mut systems_in_sets_with_conditions[i]; for &(col, sys_id) in &hg_systems { let idx = dg_system_idx_map[&sys_id]; - let is_descendant = hier_results.reachable[index(row, col, node_count)]; + let is_descendant = hier_results.reachable[index(row, col, hg_node_count)]; bitset.set(idx, is_descendant); } } @@ -1160,7 +1160,7 @@ impl ScheduleGraph { .enumerate() .take_while(|&(_idx, &row)| row < col) { - let is_ancestor = hier_results.reachable[index(row, col, node_count)]; + let is_ancestor = hier_results.reachable[index(row, col, hg_node_count)]; bitset.set(idx, is_ancestor); } } From b23ff2b19be1308eb5624918ba1ba7793ed04826 Mon Sep 17 00:00:00 2001 From: Edgar Geier Date: Wed, 2 Aug 2023 18:36:28 +0200 Subject: [PATCH 2/3] Add regression test --- crates/bevy_ecs/src/schedule/schedule.rs | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 26dec8af89279..6e1a3e82b9a05 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -1570,3 +1570,29 @@ impl ScheduleBuildSettings { } } } + +#[cfg(test)] +mod tests { + use crate::{ + self as bevy_ecs, + schedule::{IntoSystemConfigs, IntoSystemSetConfig, Schedule, SystemSet}, + world::World, + }; + + #[test] + fn ambiguous_with_not_breaking_run_conditions() { + #[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)] + struct Set; + + let mut world = World::new(); + let mut schedule = Schedule::new(); + + schedule.configure_set(Set.run_if(|| false)); + schedule.add_systems( + (|| panic!("This system must not run")) + .ambiguous_with(|| ()) + .in_set(Set), + ); + schedule.run(&mut world); + } +} From 4228f0f8efa3b5b70483f79257f3607e4442f1d9 Mon Sep 17 00:00:00 2001 From: James Liu Date: Thu, 3 Aug 2023 03:38:38 -0400 Subject: [PATCH 3/3] Add note about regression test --- crates/bevy_ecs/src/schedule/schedule.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 6e1a3e82b9a05..cb9ab0a978335 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -1579,6 +1579,7 @@ mod tests { world::World, }; + // regression test for https://github.com/bevyengine/bevy/issues/9114 #[test] fn ambiguous_with_not_breaking_run_conditions() { #[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]