@@ -1622,7 +1622,7 @@ pub fn store_property(
16221622 component_instance : InstanceRef ,
16231623 element : & ElementRc ,
16241624 name : & str ,
1625- value : Value ,
1625+ mut value : Value ,
16261626) -> Result < ( ) , SetPropertyError > {
16271627 generativity:: make_guard!( guard) ;
16281628 match enclosing_component_instance_for_element (
@@ -1653,7 +1653,7 @@ pub fn store_property(
16531653 . get ( name)
16541654 {
16551655 // Do an extra type checking because PropertyInfo::set won't do it for custom structures or array
1656- if !check_value_type ( & value, & orig_decl. property_type ) {
1656+ if !check_value_type ( & mut value, & orig_decl. property_type ) {
16571657 return Err ( SetPropertyError :: WrongType ) ;
16581658 }
16591659 }
@@ -1682,7 +1682,7 @@ pub fn store_property(
16821682}
16831683
16841684/// Return true if the Value can be used for a property of the given type
1685- fn check_value_type ( value : & Value , ty : & Type ) -> bool {
1685+ fn check_value_type ( value : & mut Value , ty : & Type ) -> bool {
16861686 match ty {
16871687 Type :: Void => true ,
16881688 Type :: Invalid
@@ -1711,10 +1711,21 @@ fn check_value_type(value: &Value, ty: &Type) -> bool {
17111711 Type :: Easing => matches ! ( value, Value :: EasingCurve ( _) ) ,
17121712 Type :: Brush => matches ! ( value, Value :: Brush ( _) ) ,
17131713 Type :: Array ( inner) => {
1714- matches ! ( value, Value :: Model ( m) if m. iter( ) . all( |v| check_value_type( & v, inner) ) )
1714+ matches ! ( value, Value :: Model ( m) if m. iter( ) . all( |mut v| check_value_type( & mut v, inner) ) )
17151715 }
17161716 Type :: Struct ( s) => {
1717- matches ! ( value, Value :: Struct ( str ) if str . iter( ) . all( |( k, v) | s. fields. get( k) . is_some_and( |ty| check_value_type( v, ty) ) ) )
1717+ let Value :: Struct ( str) = value else { return false } ;
1718+ if !str
1719+ . 0
1720+ . iter_mut ( )
1721+ . all ( |( k, v) | s. fields . get ( k) . is_some_and ( |ty| check_value_type ( v, ty) ) )
1722+ {
1723+ return false ;
1724+ }
1725+ for ( k, v) in & s. fields {
1726+ str. 0 . entry ( k. clone ( ) ) . or_insert_with ( || default_value_for_type ( v) ) ;
1727+ }
1728+ true
17181729 }
17191730 Type :: Enumeration ( en) => {
17201731 matches ! ( value, Value :: EnumerationValue ( name, _) if name == en. name. as_str( ) )
0 commit comments