Fix passing null to functions taking Object parameters

pull/864/head
Marc Gilleron 2022-09-23 21:20:37 +01:00
parent e40aa112ee
commit cd2232eddf
1 changed files with 3 additions and 1 deletions

View File

@ -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);") result.append(f"\tPtrToArg<{correct_type(type_name)}>::encode({name}, &{name}_encoded);")
name = f"&{name}_encoded" name = f"&{name}_encoded"
elif is_engine_class(type_name): 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: else:
name = f"&{name}" name = f"&{name}"