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

Use alternative for isInstanceValid #505

Closed
migueldeicaza opened this issue Jul 12, 2024 · 4 comments
Closed

Use alternative for isInstanceValid #505

migueldeicaza opened this issue Jul 12, 2024 · 4 comments

Comments

@migueldeicaza
Copy link
Owner

See this bug:

godotengine/godot-cpp#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.

@dsnopek
Copy link

dsnopek commented Jul 15, 2024

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?

@migueldeicaza
Copy link
Owner Author

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.

@dsnopek
Copy link

dsnopek commented Jul 16, 2024

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

@migueldeicaza
Copy link
Owner Author

Thank you David, I am going to close this now.

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

No branches or pull requests

2 participants