Validate instances of objects before trying to check their type in GDScript
Fixes #27582
This commit is contained in:
parent
3af0400a32
commit
dc4455d819
1 changed files with 15 additions and 7 deletions
|
@ -76,8 +76,12 @@ struct GDScriptDataType {
|
|||
if (p_variant.get_type() != Variant::OBJECT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Object *obj = p_variant.operator Object *();
|
||||
if (obj) {
|
||||
if (!obj || !ObjectDB::instance_validate(obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ClassDB::is_parent_class(obj->get_class_name(), native_type)) {
|
||||
// Try with underscore prefix
|
||||
StringName underscore_native_type = "_" + native_type;
|
||||
|
@ -85,7 +89,6 @@ struct GDScriptDataType {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} break;
|
||||
case SCRIPT:
|
||||
|
@ -96,7 +99,12 @@ struct GDScriptDataType {
|
|||
if (p_variant.get_type() != Variant::OBJECT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Object *obj = p_variant.operator Object *();
|
||||
if (!obj || !ObjectDB::instance_validate(obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Ref<Script> base = obj && obj->get_script_instance() ? obj->get_script_instance()->get_script() : NULL;
|
||||
bool valid = false;
|
||||
while (base.is_valid()) {
|
||||
|
|
Loading…
Reference in a new issue