bevy/crates/bevy_ecs/src/schedule
Eagster 5db67f35e4
Get names of queued components (#18451)
# Objective

#18173 allows components to be queued without being fully registered.
But much of bevy's debug logging contained
`components.get_name(id).unwrap()`. However, this panics when the id is
queued. This PR fixes this, allowing names to be retrieved for debugging
purposes, etc, even while they're still queued.

## Solution

We change `ComponentInfo::descriptor` to be `Arc<ComponentDescriptor>`
instead of not arc'd. This lets us pass the descriptor around (as a name
or otherwise) as needed. The alternative would require some form of
`MappedRwLockReadGuard`, which is unstable, and would be terribly
blocking. Putting it in an arc also signifies that it doesn't change,
which is a nice signal to users. This does mean there's an extra pointer
dereference, but I don't think that's an issue here, as almost all paths
that use this are for debugging purposes or one-time set ups.

## Testing

Existing tests.

## Migration Guide

`Components::get_name` now returns `Option<Cow<'_, str>` instead of
`Option<&str>`. This is because it now returns results for queued
components. If that behavior is not desired, or you know the component
is not queued, you can use
`components.get_info().map(ComponentInfo::name)` instead.

Similarly, `ScheduleGraph::conflicts_to_string` now returns `impl
Iterator<Item = (String, String, Vec<Cow<str>>)>` instead of `impl
Iterator<Item = (String, String, Vec<&str>)>`. Because `Cow<str>` derefs
to `&str`, most use cases can remain unchanged.

---------

Co-authored-by: Chris Russell <8494645+chescock@users.noreply.github.com>
2025-03-31 23:22:33 +00:00
..
executor Fix run_system for adapter systems wrapping exclusive systems (#18406) 2025-03-26 13:40:42 +00:00
graph Generic system config (#17962) 2025-03-12 00:12:30 +00:00
auto_insert_apply_deferred.rs Bubble sync points if ignore_deferred, do not ignore if target system is exclusive (#17880) 2025-02-26 20:39:23 +00:00
condition.rs Generic system config (#17962) 2025-03-12 00:12:30 +00:00
config.rs Generic system config (#17962) 2025-03-12 00:12:30 +00:00
mod.rs Get names of queued components (#18451) 2025-03-31 23:22:33 +00:00
pass.rs Schedule build pass (#11094) 2025-02-05 23:14:05 +00:00
schedule.rs Get names of queued components (#18451) 2025-03-31 23:22:33 +00:00
set.rs Harden proc macro path resolution and add integration tests. (#17330) 2025-02-09 19:45:45 +00:00
stepping.rs Add print_stdout and print_stderr lints (#17446) (#18233) 2025-03-11 19:35:48 +00:00