diff options
author | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2019-07-08 15:17:43 +0200 |
---|---|---|
committer | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2019-07-08 18:07:20 +0200 |
commit | aa3b8f7dbbf04c54795431eed40c63f9ed8e0fe1 (patch) | |
tree | eda12a2498769d11093b9b495f69319ea5112dc8 /modules/mono/glue/base_object_glue.cpp | |
parent | 5ed3d34cd914ecd6930651769a423cad2999ca64 (diff) |
Fix Godot.Object.ToString() infinite recursion
Should not be using Variant to String conversion as that would call ToString() again
Diffstat (limited to 'modules/mono/glue/base_object_glue.cpp')
-rw-r--r-- | modules/mono/glue/base_object_glue.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/modules/mono/glue/base_object_glue.cpp b/modules/mono/glue/base_object_glue.cpp index 75b2dfce9a..6d85f55b97 100644 --- a/modules/mono/glue/base_object_glue.cpp +++ b/modules/mono/glue/base_object_glue.cpp @@ -219,7 +219,18 @@ MonoBoolean godot_icall_DynamicGodotObject_SetMember(Object *p_ptr, MonoString * } MonoString *godot_icall_Object_ToString(Object *p_ptr) { - return GDMonoMarshal::mono_string_from_godot(Variant(p_ptr).operator String()); +#ifdef DEBUG_ENABLED + // Cannot happen in C#; would get an ObjectDisposedException instead. + CRASH_COND(p_ptr == NULL); + + if (ScriptDebugger::get_singleton() && !Object::cast_to<Reference>(p_ptr)) { // Only if debugging! + // Cannot happen either in C#; the handle is nullified when the object is destroyed + CRASH_COND(!ObjectDB::instance_validate(p_ptr)); + } +#endif + + String result = "[" + p_ptr->get_class() + ":" + itos(p_ptr->get_instance_id()) + "]"; + return GDMonoMarshal::mono_string_from_godot(result); } void godot_register_object_icalls() { |