@@ -1449,12 +1449,10 @@ impl Object {
1449
1449
if !properties. is_empty ( ) {
1450
1450
let klass = ObjectClass :: from_type ( type_)
1451
1451
. unwrap_or_else ( || panic ! ( "Can't retrieve class for type '{type_}'" ) ) ;
1452
- let pspecs = klass. list_properties ( ) ;
1453
1452
1454
1453
for ( idx, ( name, value) ) in properties. iter_mut ( ) . enumerate ( ) {
1455
- let pspec = pspecs
1456
- . iter ( )
1457
- . find ( |p| p. name ( ) == * name)
1454
+ let pspec = klass
1455
+ . find_property ( name)
1458
1456
. unwrap_or_else ( || panic ! ( "Can't find property '{name}' for type '{type_}'" ) ) ;
1459
1457
1460
1458
if ( pspec. flags ( ) . contains ( crate :: ParamFlags :: CONSTRUCT )
@@ -1469,7 +1467,7 @@ impl Object {
1469
1467
// FIXME: With GLib 2.74 and GParamSpecClass::value_is_valid() it is possible to
1470
1468
// not require mutable values here except for when LAX_VALIDATION is provided and a
1471
1469
// change is needed, or a GObject value needs it's GType changed.
1472
- validate_property_type ( type_, true , pspec, value) ;
1470
+ validate_property_type ( type_, true , & pspec, value) ;
1473
1471
1474
1472
property_names. push ( pspec. name ( ) . as_ptr ( ) ) ;
1475
1473
property_values. push ( * value. to_glib_none ( ) . 0 ) ;
@@ -2278,17 +2276,15 @@ impl<T: ObjectType> ObjectExt for T {
2278
2276
2279
2277
#[ track_caller]
2280
2278
fn set_properties ( & self , property_values : & [ ( & str , & dyn ToValue ) ] ) {
2281
- let pspecs = self . list_properties ( ) ;
2282
-
2283
2279
let params = property_values
2284
2280
. iter ( )
2285
2281
. map ( |& ( name, value) | {
2286
- let pspec = pspecs . iter ( ) . find ( |p| p . name ( ) == name) . unwrap_or_else ( || {
2282
+ let pspec = self . find_property ( name) . unwrap_or_else ( || {
2287
2283
panic ! ( "Can't find property '{name}' for type '{}'" , self . type_( ) ) ;
2288
2284
} ) ;
2289
2285
2290
2286
let mut value = value. to_value ( ) ;
2291
- validate_property_type ( self . type_ ( ) , false , pspec, & mut value) ;
2287
+ validate_property_type ( self . type_ ( ) , false , & pspec, & mut value) ;
2292
2288
( pspec. name ( ) . as_ptr ( ) , value)
2293
2289
} )
2294
2290
. collect :: < smallvec:: SmallVec < [ _ ; 10 ] > > ( ) ;
@@ -2307,20 +2303,15 @@ impl<T: ObjectType> ObjectExt for T {
2307
2303
2308
2304
#[ track_caller]
2309
2305
fn set_properties_from_value ( & self , property_values : & [ ( & str , Value ) ] ) {
2310
- let pspecs = self . list_properties ( ) ;
2311
-
2312
2306
let params = property_values
2313
2307
. iter ( )
2314
2308
. map ( |( name, value) | {
2315
- let pspec = pspecs
2316
- . iter ( )
2317
- . find ( |p| p. name ( ) == * name)
2318
- . unwrap_or_else ( || {
2319
- panic ! ( "Can't find property '{name}' for type '{}'" , self . type_( ) ) ;
2320
- } ) ;
2309
+ let pspec = self . find_property ( name) . unwrap_or_else ( || {
2310
+ panic ! ( "Can't find property '{name}' for type '{}'" , self . type_( ) ) ;
2311
+ } ) ;
2321
2312
2322
2313
let mut value = value. clone ( ) ;
2323
- validate_property_type ( self . type_ ( ) , false , pspec, & mut value) ;
2314
+ validate_property_type ( self . type_ ( ) , false , & pspec, & mut value) ;
2324
2315
( pspec. name ( ) . as_ptr ( ) , value)
2325
2316
} )
2326
2317
. collect :: < smallvec:: SmallVec < [ _ ; 10 ] > > ( ) ;
0 commit comments