pragmagic/godot-nim

objectDestroy does not call into the engine to free objects?

geekrelief opened this issue · 1 comments

Please ignore this issue for now. Not sure what I was doing wrong, but now my breakpoint for godot_object_destroy is being triggered. I'm continuing to research my issue.

I'm not sure if this is an issue with the nim bindings or gdnative. But it doesn't seem like

getGDNativeAPI().objectDestroy(o)
objectDestroy calls into the engine.

I have my app running via the Visual Studio debugger with a breakpoint here:https://github.com/godotengine/godot/blob/master/modules/gdnative/gdnative/gdnative.cpp#L46-L48

Then in nim I load a Curve resource in ready():
discard resource_loader.load("res://curve.tres")
When ready() finishes, I can see unreference being called through to the engine while debugging in VS, but when deinit is called the breakpoint in godot_object_destroy is not triggered.

Any idea what's going on when objectDestroy is called? It has to be pointing somewhere, but I'm not sure where.

I figured out my issue. I've been trying to get a gdns resource to load and terminate. I thought I could narrow down the issue using a simpler resource like a Curve, but that is working fine. I must have somehow debugged the wrong process which is why godot_object_destroy wasn't triggering my breakpoint.
So figuring a gdns resource is not cleaned up properly. I modified NativeScriptLanguage::unregister_script to terminate the GDNative object and clean it up. And its referenced dll is no longer locked.