Account for relative extends paths in a GDScript utility function

This commit is contained in:
Mike Precup
2025-03-12 00:47:20 -07:00
parent ee713ccb7c
commit b7e3c64766
+6 -6
View File
@@ -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<GDScriptParser::IdentifierNode *> extend_classes = subclass->extends;
Ref<FileAccess> subfile = FileAccess::open(subclass->extends_path, FileAccess::READ);
Ref<FileAccess> 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;