Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safer fix for memory leak (#81) #83

Merged
merged 2 commits into from
Nov 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions py4godot/core/variant4/type_helpers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ cdef api object type_helper_create_string(shared_ptr[bridge.String]& bridge_stri
##Py_INCREF(val)
return val


cdef Object val = None
cdef api object type_helper_create_object(shared_ptr[bridge.Object]& bridge_object):
cdef Object temp_val = Object.__new__(Object)
temp_val.Object_internal_class_ptr = bridge_object
#Py_INCREF(temp_val)
return temp_val
global val
if not val:
val = Object() # Just using object.__new__(Object) crashes. This seems to fix that
val.destroy() # Free object to not run into memory leaks
val.Object_internal_class_ptr = bridge_object
##Py_INCREF(val)
return val


cdef api object type_helper_create_py_string(shared_ptr[bridge.String]& bridge_string):
Expand Down