mirror of
https://github.com/bevyengine/bevy
synced 2024-12-23 11:33:06 +00:00
0a588dbfd9
# Objective Fixes #10444 Currently manually removing an asset prevents it from being reloaded while there are still active handles. Doing so will result in a panic, because the storage entry has been marked as "empty / None" but the ID is still assumed to be active by the asset server. Patterns like `images.remove() -> asset_server.reload()` and `images.remove() -> images.insert()` would fail if the handle was still alive. ## Solution Most of the groundwork for this was already laid in Bevy Asset V2. This is largely just a matter of splitting out `remove` into two separate operations: * `remove_dropped`: remove the stored asset, invalidate the internal Assets entry (preventing future insertions with the old id), and recycle the id * `remove_still_alive`: remove the stored asset, but leave the entry otherwise untouched (and dont recycle the id). `remove_still_alive` and `insert` can be called any number of times (in any order) for an id until `remove_dropped` has been called, which will invalidate the id. From a user-facing perspective, there are no API changes and this is non breaking. The public `Assets::remove` will internally call `remove_still_alive`. `remove_dropped` can only be called by the internal "handle management" system. --- ## Changelog - Fix a bug preventing `Assets::remove` from blocking future inserts for a specific `AssetIndex`. |
||
---|---|---|
.. | ||
macros | ||
src | ||
Cargo.toml |