From e92669654aefc18195a674db571b161aec602318 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Tue, 25 Feb 2020 01:24:18 +0100 Subject: [PATCH] Fix debugger crash inspecting freed object. This seems to be the correct way to validate a reference. Why is cast_to failing? (cherry picked from commit d8ba07ea8f2a17e77549c56ce8eddcbc2fcead7c) --- scene/debugger/script_debugger_remote.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scene/debugger/script_debugger_remote.cpp b/scene/debugger/script_debugger_remote.cpp index 04d04ceb664..56b8e813c16 100644 --- a/scene/debugger/script_debugger_remote.cpp +++ b/scene/debugger/script_debugger_remote.cpp @@ -680,13 +680,17 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) { const PropertyInfo &pi = properties[i].first; Variant &var = properties[i].second; - WeakRef *ref = Object::cast_to(var); - if (ref) { - var = ref->get_ref(); - } - RES res = var; + if (var.get_type() == Variant::OBJECT && var.is_ref()) { + REF r = var; + if (r.is_valid()) { + res = *r; + } else { + res = RES(); + } + } + Array prop; prop.push_back(pi.name); prop.push_back(pi.type);