summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorqarmin <mikrutrafal54@gmail.com>2019-07-23 09:14:31 +0200
committerqarmin <mikrutrafal54@gmail.com>2019-07-23 09:14:31 +0200
commitaab8da25ad2c3e6d2df03abbc8e35c1725938c40 (patch)
treea98f3ddd124571378b146209beb308eb2768f9bc /editor
parente466dc2daa8eee7e6fb5a7fce40bf9e988a927cb (diff)
Fix some code found by Coverity Scan and PVS Studio
Diffstat (limited to 'editor')
-rw-r--r--editor/import/editor_import_collada.cpp50
-rw-r--r--editor/import/resource_importer_scene.cpp1
-rw-r--r--editor/plugins/mesh_library_editor_plugin.cpp2
-rw-r--r--editor/scene_tree_dock.cpp2
-rw-r--r--editor/script_editor_debugger.h2
5 files changed, 30 insertions, 27 deletions
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index e152827c63..1c4a8c43a9 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -1175,35 +1175,33 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
morph = &collada.state.morph_controller_data_map[ngsource];
meshid = morph->mesh;
- Vector<String> targets;
-
- morph->targets.has("MORPH_TARGET");
- String target = morph->targets["MORPH_TARGET"];
- bool valid = false;
- if (morph->sources.has(target)) {
- valid = true;
- Vector<String> names = morph->sources[target].sarray;
- for (int i = 0; i < names.size(); i++) {
-
- String meshid2 = names[i];
- if (collada.state.mesh_data_map.has(meshid2)) {
- Ref<ArrayMesh> mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
- const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid2];
- mesh->set_name(meshdata.name);
- Error err = _create_mesh_surfaces(false, mesh, ng2->material_map, meshdata, apply_xform, bone_remap, skin, NULL, Vector<Ref<ArrayMesh> >(), false);
- ERR_FAIL_COND_V(err, err);
-
- morphs.push_back(mesh);
- } else {
- valid = false;
+ if (morph->targets.has("MORPH_TARGET")) {
+ String target = morph->targets["MORPH_TARGET"];
+ bool valid = false;
+ if (morph->sources.has(target)) {
+ valid = true;
+ Vector<String> names = morph->sources[target].sarray;
+ for (int i = 0; i < names.size(); i++) {
+
+ String meshid2 = names[i];
+ if (collada.state.mesh_data_map.has(meshid2)) {
+ Ref<ArrayMesh> mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid2];
+ mesh->set_name(meshdata.name);
+ Error err = _create_mesh_surfaces(false, mesh, ng2->material_map, meshdata, apply_xform, bone_remap, skin, NULL, Vector<Ref<ArrayMesh> >(), false);
+ ERR_FAIL_COND_V(err, err);
+
+ morphs.push_back(mesh);
+ } else {
+ valid = false;
+ }
}
}
- }
-
- if (!valid)
- morphs.clear();
- ngsource = "";
+ if (!valid)
+ morphs.clear();
+ ngsource = "";
+ }
}
if (ngsource != "") {
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 53b67c46b0..8e6a56a929 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -435,6 +435,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
Object::cast_to<Spatial>(sb)->set_transform(Object::cast_to<Spatial>(p_node)->get_transform());
p_node->replace_by(sb);
memdelete(p_node);
+ p_node = NULL;
CollisionShape *colshape = memnew(CollisionShape);
if (empty_draw_type == "CUBE") {
BoxShape *boxShape = memnew(BoxShape);
diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp
index e582f6ded2..1fc6dae978 100644
--- a/editor/plugins/mesh_library_editor_plugin.cpp
+++ b/editor/plugins/mesh_library_editor_plugin.cpp
@@ -201,6 +201,8 @@ void MeshLibraryEditor::_import_scene_cbk(const String &p_str) {
ERR_FAIL_COND(ps.is_null());
Node *scene = ps->instance();
+ ERR_FAIL_COND(!scene);
+
_import_scene(scene, mesh_library, option == MENU_OPTION_UPDATE_FROM_SCENE);
memdelete(scene);
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 009ac603e2..aeee829de2 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -301,6 +301,8 @@ bool SceneTreeDock::_track_inherit(const String &p_target_scene_path, Node *p_de
Ref<PackedScene> data = ResourceLoader::load(path);
if (data.is_valid()) {
p = data->instance(PackedScene::GEN_EDIT_STATE_INSTANCE);
+ if (!p)
+ continue;
instances.push_back(p);
} else
break;
diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h
index 505eab266f..947b0cca52 100644
--- a/editor/script_editor_debugger.h
+++ b/editor/script_editor_debugger.h
@@ -173,7 +173,7 @@ class ScriptEditorDebugger : public Control {
void _set_reason_text(const String &p_reason, MessageType p_type);
void _scene_tree_property_select_object(ObjectID p_object);
void _scene_tree_property_value_edited(const String &p_prop, const Variant &p_value);
- int _update_scene_tree(TreeItem *parent, const Array &items, int current_index);
+ int _update_scene_tree(TreeItem *parent, const Array &nodes, int current_index);
void _video_mem_request();