Merge pull request #32431 from lupoDharkael/checks

Add checks after ResourceLoader::load()
This commit is contained in:
Rémi Verschelde 2019-09-30 07:55:47 +02:00 committed by GitHub
commit ddc42be1db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 0 deletions

View File

@ -5528,6 +5528,7 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
for (int i = 0; i < files.size(); i++) {
String path = files[i];
RES res = ResourceLoader::load(path);
ERR_FAIL_COND(res.is_null());
Ref<Texture> texture = Ref<Texture>(Object::cast_to<Texture>(*res));
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
if (texture != NULL || scene != NULL) {

View File

@ -3230,6 +3230,7 @@ void SpatialEditorViewport::_create_preview(const Vector<String> &files) const {
for (int i = 0; i < files.size(); i++) {
String path = files[i];
RES res = ResourceLoader::load(path);
ERR_CONTINUE(res.is_null());
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
Ref<Mesh> mesh = Ref<Mesh>(Object::cast_to<Mesh>(*res));
if (mesh != NULL || scene != NULL) {
@ -3279,6 +3280,7 @@ bool SpatialEditorViewport::_cyclical_dependency_exists(const String &p_target_s
bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const Point2 &p_point) {
RES res = ResourceLoader::load(path);
ERR_FAIL_COND_V(res.is_null(), false);
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
Ref<Mesh> mesh = Ref<Mesh>(Object::cast_to<Mesh>(*res));

View File

@ -380,6 +380,7 @@ void VersionControlEditorPlugin::fetch_available_vcs_addon_names() {
String path = ScriptServer::get_global_class_path(global_classes[i]);
Ref<Script> script = ResourceLoader::load(path);
ERR_FAIL_COND(script.is_null());
if (script->get_instance_base_type() == "EditorVCSInterface") {