iter_mut on Assets: send modified event only when asset is iterated over (#3565)
# Objective - `Assets<T>::iter_mut` sends `Modified` event for all assets first, then returns the iterator - This means that events could be sent for assets that would not have been mutated if iteration was stopped before ## Solution - Send `Modified` event when assets are iterated over. Co-authored-by: François <8672791+mockersf@users.noreply.github.com>
This commit is contained in:
parent
6c95b582a5
commit
baae97d002
@ -186,12 +186,12 @@ impl<T: Asset> Assets<T> {
|
||||
|
||||
/// Get a mutable iterator over all assets in the collection.
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = (HandleId, &mut T)> {
|
||||
for id in self.assets.keys() {
|
||||
self.assets.iter_mut().map(|(k, v)| {
|
||||
self.events.send(AssetEvent::Modified {
|
||||
handle: Handle::weak(*id),
|
||||
handle: Handle::weak(*k),
|
||||
});
|
||||
}
|
||||
self.assets.iter_mut().map(|(k, v)| (*k, v))
|
||||
(*k, v)
|
||||
})
|
||||
}
|
||||
|
||||
/// Get an iterator over all [`HandleId`]'s in the collection.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user