Closed migueldeicaza closed 1 month ago
I don't know much about the Swift bindings, but it's entirely possible that is_instance_valid
is fine to use with Swift.
In godot-cpp, the problem is that developers can have Object *
s, and if it was deleted, and then developer calls is_instance_valid()
with that pointer, it can't actually look up the Godot-side object, because that memory is no longer valid. If we instead mandated that developers use a smart pointer-like type (rather than raw pointers), then we could implement a safe way to use is_instance_valid()
, but we're not going to do that because we want have API parity with Godot modules.
So, this might not be an issue with the Swift bindings?
Thanks for the clarity, I think we might be fine, my concern was that perhaps there was a scenario where the object was destroyed in the Godot side, but our callback was not invoked.
my concern was that perhaps there was a scenario where the object was destroyed in the Godot side, but our callback was not invoked
Nope, I'm not aware of any such scenario
Thank you David, I am going to close this now.
See this bug:
https://github.com/godotengine/godot-cpp/pull/1513
We could keep in our binding the API, but rather than invoking this method directly, we would provide the implementation that queries the database, and that would preserve compatibility, while giving us the correct behavior.