diff options
author | Gaia Clary <gaia.clary@machinimatrix.org> | 2013-02-08 04:28:58 +0400 |
---|---|---|
committer | Gaia Clary <gaia.clary@machinimatrix.org> | 2013-02-08 04:28:58 +0400 |
commit | 286d67b7145801fac588894b60a84ca0672ab2a9 (patch) | |
tree | 9678c213d93d155476947143021c74fa3c7231bd /source/blender/collada/DocumentImporter.cpp | |
parent | dbcf735636ad777db721532e30ea7a5050a17b86 (diff) |
fix null pointer issue when child nodes reference to unknown/invalid mesh
Diffstat (limited to 'source/blender/collada/DocumentImporter.cpp')
-rw-r--r-- | source/blender/collada/DocumentImporter.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 49fb713ce06..fa181d4a6e9 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -448,13 +448,23 @@ void DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent while (geom_done < geom.getCount()) { ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map, material_texture_mapping_map); - objects_done->push_back(ob); + if (ob == NULL) { + std::string id = node->getOriginalId(); + std::string name = node->getName(); + fprintf(stderr, + "<node id=\"%s\", name=\"%s\" >...contains a reference to an unknown instance_mesh.\n", + id.c_str(), + name.c_str()); + } + else { + objects_done->push_back(ob); + } ++geom_done; } while (camera_done < camera.getCount()) { ob = create_camera_object(camera[camera_done], sce); if (ob == NULL) { - std::string id = node->getOriginalId(); + std::string id = node->getOriginalId(); std::string name = node->getName(); fprintf(stderr, "<node id=\"%s\", name=\"%s\" >...contains a reference to an unknown instance_camera.\n", id.c_str(), name.c_str()); } @@ -537,6 +547,7 @@ void DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent } // if node has child nodes write them COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes(); + ob = *objects_done->begin(); for (unsigned int i = 0; i < child_nodes.getCount(); i++) { write_node(child_nodes[i], node, sce, ob, is_library_node); } |