diff options
author | Ruslan Mustakov <r.mustakov@gmail.com> | 2017-08-19 19:41:11 +0700 |
---|---|---|
committer | Ruslan Mustakov <r.mustakov@gmail.com> | 2017-09-14 19:40:36 +0700 |
commit | f08bc0df7c16a6d12292628ec8cc2e015047c450 (patch) | |
tree | 73b9bdaf5441798340bcbddcd96edc2430a9ccd0 /core/variant.cpp | |
parent | 9ac940677c9febc5f1c52782a717df61b0224344 (diff) | |
download | redot-engine-f08bc0df7c16a6d12292628ec8cc2e015047c450.tar.gz |
Construct Variants from Reference properly in GDNative
Previously godot_variant_new_object constructed Variant without
accounting for the fact that the Object can be a Reference, so refcount
was not increased and References were destructed prematurely.
Also, Reference::init_ref did not propagate refcount increment to the
script instance, which led to desync of refcount info on the script
side and Godot side.
Diffstat (limited to 'core/variant.cpp')
-rw-r--r-- | core/variant.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/variant.cpp b/core/variant.cpp index 74f6b6a711..10d86152ee 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -2259,8 +2259,8 @@ Variant::Variant(const RefPtr &p_resource) { type = OBJECT; memnew_placement(_data._mem, ObjData); - REF ref = p_resource; - _get_obj().obj = ref.ptr(); + REF *ref = reinterpret_cast<REF *>(p_resource.get_data()); + _get_obj().obj = ref->ptr(); _get_obj().ref = p_resource; } |