-
-
Notifications
You must be signed in to change notification settings - Fork 458
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
Calling a function taking a Ref<Resource> crashes #78
Comments
I have a guess... // Resource would have two refs, despite being only referenced in ref
Ref<T> ref(new Resource()); If we reference, we get a leak. But Godot has a trick. I think we miss something, here is the Godot implementation: void ref_pointer(T *p_ref) {
ERR_FAIL_COND(!p_ref);
if (p_ref->init_ref())
reference = p_ref;
} here is the C++ bindings implementation: Ref(T *r)
{
reference = r;
} Which means we... undo 2e4de7b ? That means there is something we missed at this step. The initial implementation might have been valid, but somehow a detail made it wrong... |
Let's rewrite |
I finished rewriting it... and now everything works fine. getting, setting or instance() a |
I have a
set_data
function, which does nothing yet:Which is registered this way:
If I call it in GDScript:
It produces a crash as soon as the function ends (the print gets printed before).
It looks like a double-delete.
It doesn't reproduce if I try fully in C++:
Because I am unable to debug I tried putting an assert(0)
But that's all I can see about the state of the ref:
The text was updated successfully, but these errors were encountered: