@@ -575,27 +575,22 @@ mod script_instance_info {
575
575
)
576
576
} ;
577
577
578
- let length = handle_panic ( ctx, || {
578
+ let vec = handle_panic ( ctx, || {
579
579
let instance = instance_data_as_script_instance :: < T > ( p_instance) ;
580
580
581
- borrow_instance ( instance) . get_property_list ( ) . len ( )
581
+ instance
582
+ . property_list
583
+ . lock ( )
584
+ . expect ( "mutext should not be poisoned" )
585
+ . remove ( & p_prop_info)
586
+ . expect ( "godot is trying to free the property list, but none has been set" )
582
587
} )
583
588
. unwrap_or_default ( ) ;
584
589
585
590
// SAFETY: p_prop_info is expected to have been created by get_property_list_func
586
591
// and therefore should have the same length as before. get_propery_list_func
587
592
// also guarantees that both vector length and capacity are equal.
588
- let _drop = transfer_ptr_list_from_godot ( p_prop_info, length) ;
589
-
590
- // now drop the backing data
591
- let instance = instance_data_as_script_instance :: < T > ( p_instance) ;
592
-
593
- let _drop = instance
594
- . property_list
595
- . lock ( )
596
- . expect ( "mutex should not be poisoned" )
597
- . remove ( & p_prop_info)
598
- . expect ( "we can not free a list that has not been allocated" ) ;
593
+ let _drop = transfer_ptr_list_from_godot ( p_prop_info, vec. len ( ) ) ;
599
594
}
600
595
601
596
/// # Safety
@@ -708,18 +703,23 @@ mod script_instance_info {
708
703
) {
709
704
let ctx = || format ! ( "error while calling {}::get_method_list" , type_name:: <T >( ) ) ;
710
705
711
- let length = handle_panic ( ctx, || {
706
+ let vec = handle_panic ( ctx, || {
712
707
let instance = instance_data_as_script_instance :: < T > ( p_instance) ;
713
708
714
- borrow_instance ( instance) . get_method_list ( ) . len ( )
709
+ instance
710
+ . method_list
711
+ . lock ( )
712
+ . expect ( "method_list mutext should not be poisoned" )
713
+ . remove ( & p_method_info)
714
+ . expect ( "godot is trying to free the method_list, but none has been set" )
715
715
} )
716
716
. unwrap_or_default ( ) ;
717
717
718
718
// SAFETY: p_method_info is expected to have been created by get_method_list_func and therefore should have the same length as before.
719
719
// get_method_list_func also guarantees that both vector length and capacity are equal.
720
- let vec = transfer_ptr_list_from_godot ( p_method_info, length ) ;
720
+ let vec_sys = transfer_ptr_list_from_godot ( p_method_info, vec . len ( ) ) ;
721
721
722
- vec . into_iter ( ) . for_each ( |method_info| {
722
+ vec_sys . into_iter ( ) . for_each ( |method_info| {
723
723
transfer_ptr_list_from_godot (
724
724
method_info. arguments ,
725
725
method_info. argument_count as usize ,
0 commit comments