Browse Source

Merge pull request #105546 from Splizard/fix_gdextension_tostring

Fix GDExtension `Object/Node::to_string` to check `is_valid` before returning the result
Thaddeus Crews 4 months ago
parent
commit
df78d4a866
2 changed files with 6 additions and 2 deletions
  1. 3 1
      core/object/object.cpp
  2. 3 1
      scene/main/node.cpp

+ 3 - 1
core/object/object.cpp

@@ -978,7 +978,9 @@ String Object::to_string() {
 		String ret;
 		String ret;
 		GDExtensionBool is_valid;
 		GDExtensionBool is_valid;
 		_extension->to_string(_extension_instance, &is_valid, &ret);
 		_extension->to_string(_extension_instance, &is_valid, &ret);
-		return ret;
+		if (is_valid) {
+			return ret;
+		}
 	}
 	}
 	return "<" + get_class() + "#" + itos(get_instance_id()) + ">";
 	return "<" + get_class() + "#" + itos(get_instance_id()) + ">";
 }
 }

+ 3 - 1
scene/main/node.cpp

@@ -2864,7 +2864,9 @@ String Node::to_string() {
 		String ret;
 		String ret;
 		GDExtensionBool is_valid;
 		GDExtensionBool is_valid;
 		_get_extension()->to_string(_get_extension_instance(), &is_valid, &ret);
 		_get_extension()->to_string(_get_extension_instance(), &is_valid, &ret);
-		return ret;
+		if (is_valid) {
+			return ret;
+		}
 	}
 	}
 	return (get_name() ? String(get_name()) + ":" : "") + Object::to_string();
 	return (get_name() ? String(get_name()) + ":" : "") + Object::to_string();
 }
 }