From 29bf60cc02ab62f0c107bfda409a95d0a44a2970 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Thu, 6 Jun 2024 04:43:13 +0200 Subject: [PATCH] Use GDExtension `to_string` in Node Matches the `Object::to_string` implementation. --- core/object/object.cpp | 1 + scene/main/node.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/object/object.cpp b/core/object/object.cpp index 303624e6d772..0383753f38c0 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -923,6 +923,7 @@ void Object::notification(int p_notification, bool p_reversed) { } String Object::to_string() { + // Keep this method in sync with `Node::to_string`. if (script_instance) { bool valid; String ret = script_instance->to_string(&valid); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 884fc6de074e..c6e5a4603ec4 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2583,6 +2583,7 @@ void Node::get_storable_properties(HashSet &r_storable_properties) c } String Node::to_string() { + // Keep this method in sync with `Object::to_string`. ERR_THREAD_GUARD_V(String()); if (get_script_instance()) { bool valid; @@ -2591,7 +2592,12 @@ String Node::to_string() { return ret; } } - + if (_get_extension() && _get_extension()->to_string) { + String ret; + GDExtensionBool is_valid; + _get_extension()->to_string(_get_extension_instance(), &is_valid, &ret); + return ret; + } return (get_name() ? String(get_name()) + ":" : "") + Object::to_string(); }