From 40bb90fabdbb98af9235b224d2172e4c1aeeacc9 Mon Sep 17 00:00:00 2001 From: Karroffel Date: Tue, 20 Jun 2017 21:38:21 +0200 Subject: [PATCH] fixed ptrcall cast for const Ref Some methods require a const Ref argument, the ptrcall method wrappers cast `void *` to the apropriate types. The problem is that there is no `Ref(const T *)` constructor, but since Ref modifies the refcount of a Reference anyway there's no point in a const version. The problem is that with a `const T *` constructor call, the argument gets converted to Variant first and loses all the reference information, resulting in a null reference as the argument to the constructor. --- core/reference.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/reference.h b/core/reference.h index afc097817ab..4e2d6c36c00 100644 --- a/core/reference.h +++ b/core/reference.h @@ -344,7 +344,7 @@ struct PtrToArg &> { _FORCE_INLINE_ static Ref convert(const void *p_ptr) { - return Ref(reinterpret_cast(p_ptr)); + return Ref((T *)p_ptr); } };