GDScript: Make check for exposed classes more consistent

Some places were already checking if classes from ClassDB were exposed,
while others didn't. This makes the check more consistent to avoid
disparities which can lead to crashes.
This commit is contained in:
George Marques
2024-05-06 11:16:25 -03:00
parent 22a28e07cc
commit 501c5b0900
5 changed files with 18 additions and 17 deletions

View File

@ -4677,7 +4677,7 @@ bool GDScriptParser::export_annotations(AnnotationNode *p_annotation, Node *p_ta
if (ScriptServer::is_global_class(arg_string)) {
native_class = ScriptServer::get_global_class_native_base(arg_string);
}
if (!ClassDB::class_exists(native_class)) {
if (!ClassDB::class_exists(native_class) || !ClassDB::is_class_exposed(native_class)) {
push_error(vformat(R"(Invalid argument %d of annotation "@export_node_path": The class "%s" was not found in the global scope.)", i + 1, arg_string), p_annotation->arguments[i]);
return false;
} else if (!ClassDB::is_parent_class(native_class, SNAME("Node"))) {