godot-cpp
godot-cpp copied to clipboard
WeakRef has no 'operator=' what makes class unusable.
Godot version
4.1 dev
godot-cpp version
https://github.com/godotengine/godot-cpp/pull/1113
System information
Any
Issue description
C++ class WeakRef has no methods except get_ref() and seems no way to use it in c++. Its missing functions from the engine:
void set_obj(Object *p_object);
void set_ref(const Ref<RefCounted> &p_ref);
Steps to reproduce
n/a
Minimal reproduction project
n/a
Thanks!
I haven't tested this, but looking at the code, it appears that UtilityFunctions::weakref()
can be used to make a WeakRef
.
Does that work for you?
UtilityFunctions::weakref() Does that work for you?
I've seen it before. but i think it wasn't working. I will test it again. Thank you.
UtilityFunctions::weakref() returns a Variant. And WeakRef class has no operator= so it cannot be assigned to a stored WeakRef variable. I feel like having operator= for this class is crucial.
Are you perhaps using a WeakRef
variable instead of Ref<WeakRef>
? I just tried the second and it works fine.
Are you perhaps using a
WeakRef
variable instead ofRef<WeakRef>
? I just tried the second and it works fine.
I didn't know about Ref<WeakRef>
. Probably because I was expecting something like WeakRef<Object>. Thx. I'll try.
I think this needs to be shown in the example project.