Skip to content

Commit a4a71e1

Browse files
committed
fix errors
1 parent 5202c4e commit a4a71e1

File tree

6 files changed

+137
-156
lines changed

6 files changed

+137
-156
lines changed

crates/bevy_app/src/app.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,6 @@ impl App {
235235

236236
// reassemble
237237
*self = App::from_parts(sub_apps, tls, send, recv, runner);
238-
239-
self.remove_tls_channel();
240238
}
241239

242240
/// Runs the [`App`] by calling its [runner](Self::set_runner).
@@ -927,9 +925,10 @@ impl App {
927925
type RunnerFn = Box<dyn FnOnce(App)>;
928926

929927
fn run_once(mut app: App) {
928+
let initial_plugins_state = app.plugins_state();
929+
930930
// wait for plugins to finish setting up
931-
let plugins_state = app.plugins_state();
932-
if plugins_state != PluginsState::Cleaned {
931+
if app.plugins_state() != PluginsState::Cleaned {
933932
while app.plugins_state() == PluginsState::Adding {
934933
#[cfg(not(target_arch = "wasm32"))]
935934
bevy_tasks::tick_global_task_pools_on_main_thread();
@@ -939,7 +938,7 @@ fn run_once(mut app: App) {
939938
}
940939

941940
// If plugins where cleaned before the runner start, an update already ran
942-
if plugins_state == PluginsState::Cleaned {
941+
if initial_plugins_state == PluginsState::Cleaned {
943942
return;
944943
}
945944

crates/bevy_app/src/schedule_runner.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ impl Plugin for ScheduleRunnerPlugin {
6767
let run_mode = self.run_mode;
6868
app.set_runner(move |mut app: App| {
6969
// wait for plugins to finish setting up
70-
let plugins_state = app.plugins_state();
71-
if plugins_state != PluginsState::Cleaned {
70+
if app.plugins_state() != PluginsState::Cleaned {
7271
while app.plugins_state() == PluginsState::Adding {
7372
#[cfg(not(target_arch = "wasm32"))]
7473
bevy_tasks::tick_global_task_pools_on_main_thread();
@@ -81,7 +80,7 @@ impl Plugin for ScheduleRunnerPlugin {
8180
match run_mode {
8281
RunMode::Once => {
8382
// if plugins where cleaned before the runner start, an update already ran
84-
if plugins_state != PluginsState::Cleaned {
83+
if app.plugins_state() != PluginsState::Cleaned {
8584
app.update();
8685
}
8786
}

crates/bevy_ecs/macros/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,6 @@ pub fn impl_param_set(_input: TokenStream) -> TokenStream {
198198
#param::init_state(world, &mut #meta);
199199
let #param = #param::init_state(world, &mut system_meta.clone());
200200
)*
201-
// Make the ParamSet non-send if any of its parameters are non-send.
202-
if false #(|| !#meta.is_send())* {
203-
system_meta.set_non_send();
204-
}
205201
#(
206202
system_meta
207203
.component_access_set

crates/bevy_ecs/src/storage/resource_non_send.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,15 @@ impl ThreadLocalStorage {
424424
TLS.with_borrow_mut(|tls| tls.resource_scope(f))
425425
}
426426

427+
/// Runs `f` in a scope that has access to the thread-local resources.
428+
pub fn run<F, T>(&mut self, f: F) -> T
429+
where
430+
F: FnOnce(&mut ThreadLocals) -> T,
431+
T: 'static,
432+
{
433+
TLS.with_borrow_mut(|tls| f(tls))
434+
}
435+
427436
/// Inserts a channel into `world` that systems in `world` (via [`ThreadLocal`]) can use to
428437
/// access the underlying [`ThreadLocals`].
429438
pub fn insert_channel<S>(&self, world: &mut World, sender: S)

crates/bevy_ecs/src/system/system_param.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,34 +1506,4 @@ mod tests {
15061506
schedule.add_systems(non_sync_system);
15071507
schedule.run(&mut world);
15081508
}
1509-
1510-
// Regression test for https://github.com/bevyengine/bevy/issues/10207.
1511-
#[test]
1512-
fn param_set_non_send_first() {
1513-
fn non_send_param_set(mut p: ParamSet<(NonSend<*mut u8>, ())>) {
1514-
let _ = p.p0();
1515-
p.p1();
1516-
}
1517-
1518-
let mut world = World::new();
1519-
world.insert_non_send_resource(std::ptr::null_mut::<u8>());
1520-
let mut schedule = crate::schedule::Schedule::default();
1521-
schedule.add_systems((non_send_param_set, non_send_param_set, non_send_param_set));
1522-
schedule.run(&mut world);
1523-
}
1524-
1525-
// Regression test for https://github.com/bevyengine/bevy/issues/10207.
1526-
#[test]
1527-
fn param_set_non_send_second() {
1528-
fn non_send_param_set(mut p: ParamSet<((), NonSendMut<*mut u8>)>) {
1529-
p.p0();
1530-
let _ = p.p1();
1531-
}
1532-
1533-
let mut world = World::new();
1534-
world.insert_non_send_resource(std::ptr::null_mut::<u8>());
1535-
let mut schedule = crate::schedule::Schedule::default();
1536-
schedule.add_systems((non_send_param_set, non_send_param_set, non_send_param_set));
1537-
schedule.run(&mut world);
1538-
}
15391509
}

0 commit comments

Comments
 (0)