Fix GDScript::_get_gdscript_from_variant()
crash
The crash would happen, theoretically, when getting the type of a invalid variant.
This commit is contained in:
parent
d99ea32999
commit
3684fd249e
1 changed files with 1 additions and 6 deletions
|
@ -1288,15 +1288,10 @@ String GDScript::_get_gdscript_reference_class_name(const GDScript *p_gdscript)
|
|||
}
|
||||
|
||||
GDScript *GDScript::_get_gdscript_from_variant(const Variant &p_variant) {
|
||||
Variant::Type type = p_variant.get_type();
|
||||
if (type != Variant::Type::OBJECT)
|
||||
return nullptr;
|
||||
|
||||
Object *obj = p_variant;
|
||||
if (obj == nullptr) {
|
||||
if (obj == nullptr || obj->get_instance_id().is_null()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return Object::cast_to<GDScript>(obj);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue