migueldeicaza / SwiftGodot

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

Fix destruction of externally managed variants #391

Closed tishin closed 8 months ago

tishin commented 8 months ago

Fixes #390. Not sure if it's the correct solution, but the way I see it, Variant shouldn't destroy content which wasn't initialized for that variant and is managed somewhere else.

migueldeicaza commented 8 months ago

This is roughly in the ballpark of what needs to be done.

But the problem is that this constructor can be used for legitimate ownership creation, so I would like instead to have an explicit call to the variant_copy methods on those cases. My issue is that the documentation for this is non-existent, and the ownership model that we currently have is an approximation to reality based on existing patterns and idioms.

So I would love to find what triggered this crash for you, so I can alter that codepath to call the Variant constructor that makes a copy.

migueldeicaza commented 8 months ago

Oh! I see that there is a bug linked to this!

Let me take a look.

migueldeicaza commented 8 months ago

Ok, I took a slightly different approach.

The tests work (even if I can not run them on Xcode anymore)