Merge pull request #53135 from briansemrau/fix-ref-leak

This commit is contained in:
Rémi Verschelde 2022-06-28 17:26:44 +02:00 committed by GitHub
commit 622b656c40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -304,6 +304,13 @@ public:
v->_get_obj().id = ObjectID();
}
static void update_object_id(Variant *v) {
const Object *o = v->_get_obj().obj;
if (o) {
v->_get_obj().id = o->get_instance_id();
}
}
_FORCE_INLINE_ static void *get_opaque_pointer(Variant *v) {
switch (v->type) {
case Variant::NIL:

View file

@ -1897,7 +1897,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
VariantInternal::initialize(ret, Variant::OBJECT);
Object **ret_opaque = VariantInternal::get_object(ret);
method->ptrcall(base_obj, argptrs, ret_opaque);
VariantInternal::object_assign(ret, *ret_opaque); // Set so ID is correct too.
VariantInternal::update_object_id(ret);
#ifdef DEBUG_ENABLED
if (GDScriptLanguage::get_singleton()->profiling) {