diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index d286f7971a..ef562332f2 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -2727,15 +2727,19 @@ String GDScriptLanguage::_get_global_class_name(const String &p_path, String *r_ while (subclass) { if (subclass->extends_used) { if (!subclass->extends_path.is_empty()) { + String subpath = subclass->extends_path; + if (subpath.is_relative_path()) { + subpath = path.get_base_dir().path_join(subpath).simplify_path(); + } 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, nullptr, nullptr, nullptr, r_visited); + _ALLOW_DISCARD_ _get_global_class_name(subpath, r_base_type, nullptr, nullptr, nullptr, r_visited); subclass = nullptr; break; } else { Vector extend_classes = subclass->extends; - Ref subfile = FileAccess::open(subclass->extends_path, FileAccess::READ); + Ref subfile = FileAccess::open(subpath, FileAccess::READ); if (subfile.is_null()) { break; } @@ -2744,10 +2748,6 @@ String GDScriptLanguage::_get_global_class_name(const String &p_path, String *r_ if (subsource.is_empty()) { break; } - String subpath = subclass->extends_path; - if (subpath.is_relative_path()) { - subpath = path.get_base_dir().path_join(subpath).simplify_path(); - } if (OK != subparser.parse(subsource, subpath, false)) { break;