Skip to content

Commit 6cf907d

Browse files
committed
test
1 parent fdeb537 commit 6cf907d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

crates/bevy_ecs/src/storage/resource_non_send.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,13 @@ impl ThreadLocalStorage {
382382
Self::default()
383383
}
384384

385+
/// Removes all resources.
386+
pub fn clear(&mut self) {
387+
// Drop resources normally to avoid the caveats described in
388+
// https://doc.rust-lang.org/std/thread/struct.LocalKey.html
389+
TLS.replace(ThreadLocals::new());
390+
}
391+
385392
/// Inserts a new resource with its default value.
386393
///
387394
/// If the resource already exists, nothing happens.

crates/bevy_winit/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,9 @@ mod runner {
18401840
tls.remove_resource::<crate::EventLoopWindowTarget<AppEvent>>();
18411841
}
18421842
AppEvent::Exit(_) => {
1843+
let tls = locals.as_mut().unwrap();
1844+
tls.clear();
1845+
18431846
*control_flow = ControlFlow::Exit;
18441847
}
18451848
AppEvent::Error(payload) => {

0 commit comments

Comments
 (0)