diff options
author | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2019-07-03 09:49:46 +0200 |
---|---|---|
committer | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2019-07-05 09:38:28 +0200 |
commit | aa9908e4f601e368517c6f23406e8c15e3f197a3 (patch) | |
tree | 99b80f4c492d5a8aabf15e3f1b7ce743bd77bff6 | |
parent | 270af6fa089ccfb93ace68ada8d476bd902b10fa (diff) |
Script API methods must return Ref<T> instead of Reference*
ptrcall assumes methods that return a Reference type do so with Ref<T>. Returning Reference* from a method exposed to the scripting API completely breaks ptrcalls to this method (it can be quite hard to debug!).
-rw-r--r-- | editor/editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/editor_plugin.h | 2 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.h | 2 | ||||
-rw-r--r-- | modules/mono/editor/bindings_generator.cpp | 7 |
4 files changed, 10 insertions, 3 deletions
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 90d6c3a983..c2a845653e 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -220,7 +220,7 @@ EditorSelection *EditorInterface::get_selection() { return EditorNode::get_singleton()->get_editor_selection(); } -EditorSettings *EditorInterface::get_editor_settings() { +Ref<EditorSettings> EditorInterface::get_editor_settings() { return EditorSettings::get_singleton(); } diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index ec369bbdbb..75c230adb7 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -87,7 +87,7 @@ public: EditorSelection *get_selection(); //EditorImportExport *get_import_export(); - EditorSettings *get_editor_settings(); + Ref<EditorSettings> get_editor_settings(); EditorResourcePreview *get_resource_previewer(); EditorFileSystem *get_resource_file_system(); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 3bddc6d6d4..0404115269 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -119,7 +119,7 @@ public: void set_spatial_node(Spatial *p_node); Spatial *get_spatial_node() const { return spatial_node; } - EditorSpatialGizmoPlugin *get_plugin() const { return gizmo_plugin; } + Ref<EditorSpatialGizmoPlugin> get_plugin() const { return gizmo_plugin; } Vector3 get_handle_pos(int p_idx) const; bool intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum); bool intersect_ray(Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle = NULL, bool p_sec_first = false); 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) { |