Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Box<dyn Reflect> struct with a hashmap in it panicking when clone_value is called on it #8184

Merged
merged 9 commits into from
Apr 22, 2023
5 changes: 4 additions & 1 deletion crates/bevy_reflect/src/impls/std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,10 @@ macro_rules! impl_reflect_for_hashmap {
let mut dynamic_map = DynamicMap::default();
dynamic_map.set_name(self.type_name().to_string());
for (k, v) in self {
dynamic_map.insert_boxed(k.clone_value(), v.clone_value());
let key = K::from_reflect(k).unwrap_or_else(|| {
panic!("Attempted to clone invalid key of type {}.", k.type_name())
});
dynamic_map.insert_boxed(Box::new(key), v.clone_value());
}
dynamic_map
}
Expand Down