Skip to content

Commit 5c65340

Browse files
committed
Add missing __del__ to RefCounted class
1 parent b91525b commit 5c65340

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/godot/classes.pyx.j2

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,19 @@ cdef object _load_class(str name):
173173

174174
attrs["new"] = _new
175175

176+
def _del(self):
177+
cdef BaseGDObject obj = <BaseGDObject>self
178+
if _object_call(obj._gd_ptr, "unreference", []):
179+
gdptrs.gdptr_object_destroy(obj._gd_ptr)
180+
obj._gd_ptr = NULL
181+
182+
attrs["__del__"] = _del
183+
184+
def _free(self):
185+
raise RuntimeError("RefCounted Godot object cannot be freed")
186+
187+
attrs["free"] = _free
188+
176189
def _init(self):
177190
cdef gd_string_name_t name = gdapi.gd_string_name_from_unchecked_pystr(type(self).__name__)
178191
(<BaseGDObject>self)._gd_ptr = gdptrs.gdptr_classdb_construct_object(&name)

0 commit comments

Comments
 (0)