summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--binding_generator.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/binding_generator.py b/binding_generator.py
index 5ce6db9..95ca88d 100644
--- a/binding_generator.py
+++ b/binding_generator.py
@@ -1664,7 +1664,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}"