From 38beb1c94b5221b975dbfa10e2e4dd272325894c Mon Sep 17 00:00:00 2001 From: M4rchyS Date: Tue, 18 Nov 2025 15:42:30 +0100 Subject: [PATCH] Fix GDScript extends path recursion to itself --- modules/gdscript/gdscript.cpp | 13 ++++++++++++- modules/gdscript/gdscript.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index f3d0410a64f..c75a70d3bea 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -2826,6 +2826,17 @@ bool GDScriptLanguage::handles_global_class_type(const String &p_type) const { } String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path, bool *r_is_abstract, bool *r_is_tool) const { + LocalVector r_vec; + return _get_global_class_name(p_path, r_base_type, r_icon_path, r_is_abstract, r_is_tool, r_vec); +} + +String GDScriptLanguage::_get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path, bool *r_is_abstract, bool *r_is_tool, LocalVector &r_visited) const { + if (r_visited.has(p_path)) { + return String(); + } + + r_visited.push_back(p_path); + Error err; Ref f = FileAccess::open(p_path, FileAccess::READ, &err); if (err) { @@ -2865,7 +2876,7 @@ String GDScriptLanguage::get_global_class_name(const String &p_path, String *r_b if (!subclass->extends_path.is_empty()) { if (subclass->extends.is_empty()) { // We only care about the referenced class_name. - _ALLOW_DISCARD_ get_global_class_name(subclass->extends_path, r_base_type); + _ALLOW_DISCARD_ _get_global_class_name(subclass->extends_path, r_base_type, nullptr, nullptr, nullptr, r_visited); subclass = nullptr; break; } else { diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h index a9d9c867f2f..3af83ba8ad1 100644 --- a/modules/gdscript/gdscript.h +++ b/modules/gdscript/gdscript.h @@ -454,6 +454,8 @@ class GDScriptLanguage : public ScriptLanguage { void _add_global(const StringName &p_name, const Variant &p_value); void _remove_global(const StringName &p_name); + String _get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path, bool *r_is_abstract, bool *r_is_tool, LocalVector &r_visited) const; + friend class GDScriptInstance; Mutex mutex;