mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Avoid losing references to objects in the native-scripting boundary
This commit is contained in:
parent
1ed549e64b
commit
0bcc7bb5c7
3 changed files with 40 additions and 1 deletions
|
@ -1969,7 +1969,13 @@ 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::update_object_id(ret);
|
||||
if (method->is_return_type_raw_object_ptr()) {
|
||||
// The Variant has to participate in the ref count since the method returns a raw Object *.
|
||||
VariantInternal::object_assign(ret, *ret_opaque);
|
||||
} else {
|
||||
// The method, in case it returns something, returns an already encapsulated object.
|
||||
VariantInternal::update_object_id(ret);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (GDScriptLanguage::get_singleton()->profiling) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue