fix crash when x3d is empty

pull/2966/head
Kim Kulling 2020-09-02 21:49:40 +02:00
parent 34f343233e
commit 0b8ed5c03a
2 changed files with 7 additions and 3 deletions

View File

@ -118,14 +118,16 @@ ColladaParser::ColladaParser(IOSystem *pIOHandler, const std::string &pFile) :
} }
// generate a XML reader for it // generate a XML reader for it
;
if (!mXmlParser.parse(daefile.get())) { if (!mXmlParser.parse(daefile.get())) {
ThrowException("Unable to read file, malformed XML"); ThrowException("Unable to read file, malformed XML");
} }
// start reading // start reading
XmlNode node = mXmlParser.getRootNode(); XmlNode node = mXmlParser.getRootNode();
std::string name = node.name(); XmlNode colladaNode = node.child("COLLADA");
ReadContents(node); if (colladaNode.empty()) {
return;
}
ReadContents(colladaNode);
// read embedded textures // read embedded textures
if (zip_archive && zip_archive->isOpen()) { if (zip_archive && zip_archive->isOpen()) {

View File

@ -194,6 +194,8 @@ void X3DImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
pIOHandler->PushDirectory(slashPos == std::string::npos ? std::string() : pFile.substr(0, slashPos + 1)); pIOHandler->PushDirectory(slashPos == std::string::npos ? std::string() : pFile.substr(0, slashPos + 1));
ParseFile(pFile, pIOHandler); ParseFile(pFile, pIOHandler);
pIOHandler->PopDirectory(); pIOHandler->PopDirectory();
if (NodeElement_List.empty())
return;
// //
// Assimp use static arrays of objects for fast speed of rendering. That's good, but need some additional operations/ // Assimp use static arrays of objects for fast speed of rendering. That's good, but need some additional operations/
// We know that geometry objects(meshes) are stored in <Shape>, also in <Shape>-><Appearance> materials(in Assimp logical view) // We know that geometry objects(meshes) are stored in <Shape>, also in <Shape>-><Appearance> materials(in Assimp logical view)