1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-31 18:41:20 +00:00

Fix GDScript extends path recursion to itself

This commit is contained in:
M4rchyS
2025-11-18 15:42:30 +01:00
parent 1ea6b0ccff
commit 38beb1c94b
2 changed files with 14 additions and 1 deletions

View File

@@ -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<String> 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<String> &r_visited) const {
if (r_visited.has(p_path)) {
return String();
}
r_visited.push_back(p_path);
Error err;
Ref<FileAccess> 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 {

View File

@@ -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<String> &r_visited) const;
friend class GDScriptInstance;
Mutex mutex;