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 d8ba07ea8f)
This commit is contained in:
Fabio Alessandrelli 2020-02-25 01:24:18 +01:00 committed by Rémi Verschelde
parent 105b7468b1
commit e92669654a
1 changed files with 9 additions and 5 deletions

View File

@ -680,13 +680,17 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
const PropertyInfo &pi = properties[i].first; const PropertyInfo &pi = properties[i].first;
Variant &var = properties[i].second; Variant &var = properties[i].second;
WeakRef *ref = Object::cast_to<WeakRef>(var);
if (ref) {
var = ref->get_ref();
}
RES res = var; 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; Array prop;
prop.push_back(pi.name); prop.push_back(pi.name);
prop.push_back(pi.type); prop.push_back(pi.type);