diff --git a/core/src/loader.rs b/core/src/loader.rs index e90955e2205cc..890476df44db0 100644 --- a/core/src/loader.rs +++ b/core/src/loader.rs @@ -355,15 +355,17 @@ impl<'gc> LoadManager<'gc> { /// /// This also removes all movie loaders that have completed. pub fn movie_clip_on_load(&mut self, queue: &mut ActionQueue<'gc>) { - let mut invalidated_loaders = vec![]; + let mut loaders: Vec<_> = self.0.keys().collect(); + loaders.reverse(); - for (index, loader) in self.0.iter_mut() { - if loader.movie_clip_loaded(queue) { - invalidated_loaders.push(index); - } - } + loaders.retain(|handle| { + self.0 + .get_mut(*handle) + .expect("valid key") + .movie_clip_loaded(queue) + }); - for index in invalidated_loaders { + for index in loaders { self.0.remove(index); } }