From 46fc451b9c21e6677d0693c6298e4219f8674beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Tue, 1 Dec 2020 12:34:40 +0100 Subject: [PATCH] Remove useless check in GDScript The removed check was adding a protection for the case where a `Reference` has not yet got its reference count initialized and a script is called on it. That would cause the object to be released after the call. The removed code was constructing the `Variant` via the `Object` constructor so it didn't deal with the reference count and so the release was prevented. However, `Variant` no longer works that way so that check was useless. Now it's just illegal to run GDScript on a Reference whose reference count has not been initialized. --- modules/gdscript/gdscript_function.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index db23adb35cb..33ac9e05ad6 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -374,12 +374,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a } if (p_instance) { - if (p_instance->base_ref && static_cast(p_instance->owner)->is_referenced()) { - - self = REF(static_cast(p_instance->owner)); - } else { - self = p_instance->owner; - } + self = p_instance->owner; script = p_instance->script.ptr(); } else { script = _script;