From 3233083f63dc668b8dd21290d25a511212f114d8 Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Sun, 3 Feb 2019 06:35:22 +0100 Subject: Mono: Lifetime fixes for CSharpInstance and instance binding data Avoid CSharpInstance from accessing its state after self destructing (by deleting the Reference owner). It's now safe to replace the script instance without leaking or crashing. Also fixed godot_icall_Object_weakref return reference being freed before returning. --- core/object.cpp | 5 +++++ core/object.h | 1 + 2 files changed, 6 insertions(+) (limited to 'core') diff --git a/core/object.cpp b/core/object.cpp index 682586a7ab..05e661baab 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1924,6 +1924,11 @@ void *Object::get_script_instance_binding(int p_script_language_index) { return _script_instance_bindings[p_script_language_index]; } +bool Object::has_script_instance_binding(int p_script_language_index) { + + return _script_instance_bindings[p_script_language_index] != NULL; +} + Object::Object() { _class_ptr = NULL; diff --git a/core/object.h b/core/object.h index a5bb6dea5d..5bfef8a439 100644 --- a/core/object.h +++ b/core/object.h @@ -729,6 +729,7 @@ public: //used by script languages to store binding data void *get_script_instance_binding(int p_script_language_index); + bool has_script_instance_binding(int p_script_language_index); void clear_internal_resource_paths(); -- cgit v1.2.3