migueldeicaza / SwiftGodot

New Godot bindings for Swift
https://migueldeicaza.github.io/SwiftGodotDocs/tutorials/swiftgodot-tutorials/
MIT License
1.07k stars 70 forks source link

Add RefCounted.unref() to manage lifetime of RefCounted objects #375

Open pcbeard opened 7 months ago

pcbeard commented 7 months ago

This calls existing extension function object_destroy() when the object's reference count goes to 0.

It is a partial solution to this issue https://github.com/migueldeicaza/SwiftGodotKit/issues/25.

pcbeard commented 7 months ago

To truly fix this completely we might want to define a property wrapper for owned references to RefCounted objects. Currently our RefCounted class makes no ownership assumptions.

migueldeicaza commented 7 months ago

Related fix, we currently leak variants, which is only a problem with those that come with juicy payloads.

I have a patch for that, that I have been testing. This no longer crashes for me:

https://gist.github.com/migueldeicaza/652c9665459cf05a3cad856ad91d11c8

migueldeicaza commented 7 months ago

I have manually merged the 'unref' bits.

I would love to merge some of the overall build-system changes to build on Linux, independently of the actual test suite changes. I think those would be nice to have while we sort out the rest.

migueldeicaza commented 3 weeks ago

A more complete and comprehensive fix is now part of 0.45 (about to be released).

migueldeicaza commented 3 weeks ago

Reopening, as this has other interesting bits