File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -520,12 +520,14 @@ where
520
520
521
521
unsafe fn move_return_ptr ( self , ptr : sys:: GDExtensionTypePtr , call_type : PtrcallType ) {
522
522
if T :: DynMemory :: pass_as_ref ( call_type) {
523
- interface_fn ! ( ref_set_object) ( ptr as sys:: GDExtensionRefPtr , self . obj_sys ( ) )
523
+ // ref_set_object creates a new Ref<T> in the engine and increments the reference count. We have to drop our Gd<T> to decrement
524
+ // the reference count again.
525
+ interface_fn ! ( ref_set_object) ( ptr as sys:: GDExtensionRefPtr , self . obj_sys ( ) ) ;
524
526
} else {
525
- ptr:: write ( ptr as * mut _ , self . obj )
527
+ ptr:: write ( ptr as * mut _ , self . obj ) ;
528
+ // We've passed ownership to caller.
529
+ std:: mem:: forget ( self ) ;
526
530
}
527
- // We've passed ownership to caller.
528
- std:: mem:: forget ( self ) ;
529
531
}
530
532
}
531
533
You can’t perform that action at this time.
0 commit comments