From f08bc0df7c16a6d12292628ec8cc2e015047c450 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Sat, 19 Aug 2017 19:41:11 +0700 Subject: 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. --- core/reference.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/reference.h') diff --git a/core/reference.h b/core/reference.h index ca3ae6041..bafc16427 100644 --- a/core/reference.h +++ b/core/reference.h @@ -51,7 +51,7 @@ protected: public: _FORCE_INLINE_ bool is_referenced() const { return refcount_init.get() < 1; } bool init_ref(); - void reference(); + bool reference(); // returns false if refcount is at zero and didn't get increased bool unreference(); int reference_get_count() const; -- cgit v1.2.3-70-g09d2