Fix Variant Ref<> assignment.

-Creating from object pointer via funcptr API was missing reference initialization.
-Supersedes https://github.com/godotengine/godot-cpp/pull/662
-Fixes several crashes in GDExtension
This commit is contained in:
reduz
2022-02-11 12:30:49 +01:00
parent 3aa7b7eaf2
commit 3ad3a43063
3 changed files with 21 additions and 4 deletions

View File

@@ -1023,6 +1023,13 @@ bool Variant::is_null() const {
}
}
bool Variant::initialize_ref(Object *p_object) {
RefCounted *ref_counted = const_cast<RefCounted *>(static_cast<const RefCounted *>(p_object));
if (!ref_counted->init_ref()) {
return false;
}
return true;
}
void Variant::reference(const Variant &p_variant) {
switch (type) {
case NIL: