Fix Box<dyn Reflect> struct with a hashmap in it panicking when clone_value is called on it (#8184)
# Objective - Fix the issue described in #8183: Box<dyn Reflect> structs with a hashmap in them will panic when clone_value is called on it - Fixes: #8183 ## Solution - Updates the implementation of Reflect for Hashmaps to make clone_value call from_reflect on the key before inserting it into the new struct
This commit is contained in:
parent
37ad73d8fc
commit
a9f766ceb2
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user