Browse Source

Fix encoding/decoding of null objects.

Fabio Alessandrelli 3 years ago
parent
commit
ea7324afe8
1 changed files with 2 additions and 2 deletions
  1. 2 2
      include/godot_cpp/core/method_ptrcall.hpp

+ 2 - 2
include/godot_cpp/core/method_ptrcall.hpp

@@ -169,7 +169,7 @@ struct PtrToArg<T *> {
 	}
 	typedef Object *EncodeT;
 	_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
-		*((void **)p_ptr) = p_var->_owner;
+		*((void **)p_ptr) = p_var ? p_var->_owner : nullptr;
 	}
 };
 
@@ -180,7 +180,7 @@ struct PtrToArg<const T *> {
 	}
 	typedef const Object *EncodeT;
 	_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
-		*((void **)p_ptr) = p_var->_owner;
+		*((void **)p_ptr) = p_var ? p_var->_owner : nullptr;
 	}
 };