瀏覽代碼

Fix debugger crash inspecting freed object.

This seems to be the correct way to validate a reference.
Why is cast_to failing? Is this the correct way of checking if the
object is valid?
Fabio Alessandrelli 5 年之前
父節點
當前提交
d8ba07ea8f
共有 1 個文件被更改,包括 9 次插入5 次删除
  1. 9 5
      scene/debugger/scene_debugger.cpp

+ 9 - 5
scene/debugger/scene_debugger.cpp

@@ -347,13 +347,17 @@ void SceneDebuggerObject::serialize(Array &r_arr, int p_max_size) {
 		const PropertyInfo &pi = properties[i].first;
 		Variant &var = properties[i].second;
 
-		WeakRef *ref = Object::cast_to<WeakRef>(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);