From aa9908e4f601e368517c6f23406e8c15e3f197a3 Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Wed, 3 Jul 2019 09:49:46 +0200 Subject: Script API methods must return Ref instead of Reference* ptrcall assumes methods that return a Reference type do so with Ref. Returning Reference* from a method exposed to the scripting API completely breaks ptrcalls to this method (it can be quite hard to debug!). --- modules/mono/editor/bindings_generator.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'modules/mono/editor/bindings_generator.cpp') diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index ebf317f08b..1a440e5ced 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -2326,6 +2326,13 @@ void BindingsGenerator::_populate_object_type_interfaces() { imethod.return_type.is_enum = true; } else if (return_info.class_name != StringName()) { imethod.return_type.cname = return_info.class_name; + if (!imethod.is_virtual && ClassDB::is_parent_class(return_info.class_name, name_cache.type_Reference) && return_info.hint != PROPERTY_HINT_RESOURCE_TYPE) { + /* clang-format off */ + ERR_PRINTS("Return type is reference but hint is not " _STR(PROPERTY_HINT_RESOURCE_TYPE) "." + " Are you returning a reference type by pointer? Method: " + itype.name + "." + imethod.name); + /* clang-format on */ + ERR_FAIL(); + } } else if (return_info.hint == PROPERTY_HINT_RESOURCE_TYPE) { imethod.return_type.cname = return_info.hint_string; } else if (return_info.type == Variant::NIL && return_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT) { -- cgit v1.2.3