Skip to content

Commit bb56706

Browse files
authored
Merge pull request #1616 from dsnopek/ptrtoarg-no-error-for-null-ref
Don't print an error when decoding a null Ref<T>
2 parents 5255034 + 7f02301 commit bb56706

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

include/godot_cpp/classes/ref.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ template <typename T>
230230
struct PtrToArg<Ref<T>> {
231231
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
232232
GDExtensionRefPtr ref = (GDExtensionRefPtr)p_ptr;
233-
ERR_FAIL_NULL_V(p_ptr, Ref<T>());
233+
if (unlikely(!p_ptr)) {
234+
return Ref<T>();
235+
}
234236
return Ref<T>(reinterpret_cast<T *>(godot::internal::get_object_instance_binding(godot::internal::gdextension_interface_ref_get_object(ref))));
235237
}
236238

@@ -254,7 +256,9 @@ struct PtrToArg<const Ref<T> &> {
254256

255257
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
256258
GDExtensionRefPtr ref = const_cast<GDExtensionRefPtr>(p_ptr);
257-
ERR_FAIL_NULL_V(p_ptr, Ref<T>());
259+
if (unlikely(!p_ptr)) {
260+
return Ref<T>();
261+
}
258262
return Ref<T>(reinterpret_cast<T *>(godot::internal::get_object_instance_binding(godot::internal::gdextension_interface_ref_get_object(ref))));
259263
}
260264
};

0 commit comments

Comments
 (0)