File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -70,13 +70,7 @@ impl ElementType {
70
70
pub fn class_id ( & self ) -> Option < ClassId > {
71
71
match self {
72
72
ElementType :: Class ( class_name) => Some ( * class_name) ,
73
- ElementType :: ScriptClass ( script) => {
74
- // For script classes, we return the native base class name
75
- script. script ( ) . map ( |s| {
76
- let base_type = s. get_instance_base_type ( ) ;
77
- ClassId :: new_dynamic ( base_type. to_string ( ) )
78
- } )
79
- }
73
+ ElementType :: ScriptClass ( script) => script. base_class_id ( ) ,
80
74
_ => None ,
81
75
}
82
76
}
@@ -228,4 +222,14 @@ impl ElementScript {
228
222
// Note: might also fail in the future if acquired on another thread.
229
223
Gd :: try_from_instance_id ( self . script_instance_id ) . ok ( )
230
224
}
225
+
226
+ /// Returns the native base class of the script.
227
+ ///
228
+ /// Typically, this corresponds to the class mentioned in `extends` in GDScript.
229
+ pub fn base_class_id ( & self ) -> Option < ClassId > {
230
+ self . script ( ) . map ( |s| {
231
+ let base_type = s. get_instance_base_type ( ) ;
232
+ ClassId :: new_dynamic ( base_type. to_string ( ) )
233
+ } )
234
+ }
231
235
}
Original file line number Diff line number Diff line change @@ -748,8 +748,8 @@ where
748
748
sys:: interface_fn!( object_destroy) ( self . raw . obj_sys ( ) ) ;
749
749
}
750
750
751
- // TODO: this might leak associated data in Gd<T>, e.g. ClassId .
752
- std :: mem :: forget ( self ) ;
751
+ // Deallocate associated data in Gd, without destroying the object pointer itself (already done above) .
752
+ self . drop_weak ( )
753
753
}
754
754
}
755
755
You can’t perform that action at this time.
0 commit comments