From cd2232eddf82d609e3d2de39011c4a6a6fdafe57 Mon Sep 17 00:00:00 2001 From: Marc Gilleron Date: Fri, 23 Sep 2022 21:20:37 +0100 Subject: [PATCH] Fix passing null to functions taking Object parameters --- binding_generator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/binding_generator.py b/binding_generator.py index c1e2a69..6294fd5 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -1587,7 +1587,9 @@ def get_encoded_arg(arg_name, type_name, type_meta): result.append(f"\tPtrToArg<{correct_type(type_name)}>::encode({name}, &{name}_encoded);") name = f"&{name}_encoded" elif is_engine_class(type_name): - name = f"{name}->_owner" + # `{name}` is a C++ wrapper, it contains a field which is the object's pointer Godot expects. + # We have to check `nullptr` because when the caller sends `nullptr`, the wrapper itself will be null. + name = f"({name} != nullptr ? {name}->_owner : nullptr)" else: name = f"&{name}"