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

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

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

pcbeard
Copy link
Contributor

@pcbeard pcbeard commented Jan 30, 2024

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

It is a partial solution to this issue migueldeicaza/SwiftGodotKit#25.

@pcbeard
Copy link
Contributor Author

pcbeard commented Jan 30, 2024

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
Copy link
Owner

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
Copy link
Owner

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.

pcbeard and others added 18 commits February 15, 2024 21:44
This calls new extension function mem_release() to decrement reference
count and actually delete object when it goes to 0.
This already existed in the extension functions.

Rename system library to libgodot_system, for use by target
SwiftGodotTestability.
On macOS use .binaryTarget(name: "libgodot_binary") and reference with
libgodot_dependency.

On other platforms use .systemLibrary(name: "libgodot_system") and
reference with libgodot_dependency.
Use local blocks instead to ensure memory is cleaned up.
Change libgodot target dependencies to "libgodot_tests" on macOS.
displayserver_set_runloop sets up a callback to give time to the
main runloop.

main_iteration calls Main::iteration() to give time to the Godot
main loop.
Also starts a timer that calls Main::iteration() while runloop has
control. This is needed for when XCTest blocks the runloop until
test expectations are finished.
This ensures all tests are run from inside a live Godot engine.

Simplify GodotTestCase

Avoids the need to use platform-specific XCTest details to arrange
for a GodotEngine to be running during tests.
@migueldeicaza
Copy link
Owner

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

@migueldeicaza
Copy link
Owner

Reopening, as this has other interesting bits

@migueldeicaza migueldeicaza reopened this Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants