IrrImporter: Fix release functions.

pull/958/merge
Kim Kulling 2016-09-05 10:48:30 +02:00
parent 8f808f0e2e
commit 9e19b5103c
1 changed files with 15 additions and 15 deletions

View File

@ -116,14 +116,14 @@ const aiImporterDesc* IRRMeshImporter::GetInfo () const
return &desc; return &desc;
} }
static void releaseMaterial( aiMaterial **mat ) { static void releaseMaterial( aiMaterial *mat ) {
delete mat; delete mat;
*mat = nullptr; mat = nullptr;
} }
static void releaseMesh( aiMesh **mesh ) { static void releaseMesh( aiMesh *mesh ) {
delete mesh; delete mesh;
*mesh = nullptr; mesh = nullptr;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -170,8 +170,8 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
// end of previous buffer. A material and a mesh should be there // end of previous buffer. A material and a mesh should be there
if ( !curMat || !curMesh) { if ( !curMat || !curMesh) {
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material"); DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
releaseMaterial( &curMat ); releaseMaterial( curMat );
releaseMesh( &curMesh ); releaseMesh( curMesh );
} else { } else {
materials.push_back(curMat); materials.push_back(curMat);
meshes.push_back(curMesh); meshes.push_back(curMesh);
@ -192,7 +192,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
if (!ASSIMP_stricmp(reader->getNodeName(),"material")) { if (!ASSIMP_stricmp(reader->getNodeName(),"material")) {
if (curMat) { if (curMat) {
DefaultLogger::get()->warn("IRRMESH: Only one material description per buffer, please"); DefaultLogger::get()->warn("IRRMESH: Only one material description per buffer, please");
releaseMaterial( &curMat ); releaseMaterial( curMat );
} }
curMat = ParseMaterial(curMatFlags); curMat = ParseMaterial(curMatFlags);
} }
@ -204,8 +204,8 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
// This is possible ... remove the mesh from the list and skip further reading // This is possible ... remove the mesh from the list and skip further reading
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero vertices"); DefaultLogger::get()->warn("IRRMESH: Found mesh with zero vertices");
releaseMaterial( &curMat ); releaseMaterial( curMat );
releaseMesh( &curMesh ); releaseMesh( curMesh );
textMeaning = 0; textMeaning = 0;
continue; continue;
} }
@ -248,7 +248,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
vertexFormat = 2; vertexFormat = 2;
} }
else if (ASSIMP_stricmp("standard", t)) { else if (ASSIMP_stricmp("standard", t)) {
releaseMaterial( &curMat ); releaseMaterial( curMat );
DefaultLogger::get()->warn("IRRMESH: Unknown vertex format"); DefaultLogger::get()->warn("IRRMESH: Unknown vertex format");
} }
else vertexFormat = 0; else vertexFormat = 0;
@ -256,7 +256,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
} }
else if (!ASSIMP_stricmp(reader->getNodeName(),"indices")) { else if (!ASSIMP_stricmp(reader->getNodeName(),"indices")) {
if (curVertices.empty() && curMat) { if (curVertices.empty() && curMat) {
releaseMaterial( &curMat ); releaseMaterial( curMat );
throw DeadlyImportError("IRRMESH: indices must come after vertices"); throw DeadlyImportError("IRRMESH: indices must come after vertices");
} }
@ -272,10 +272,10 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero indices"); DefaultLogger::get()->warn("IRRMESH: Found mesh with zero indices");
// mesh - away // mesh - away
releaseMesh( &curMesh ); releaseMesh( curMesh );
// material - away // material - away
releaseMaterial( &curMat ); releaseMaterial( curMat );
textMeaning = 0; textMeaning = 0;
continue; continue;
@ -487,8 +487,8 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
if (curMat || curMesh) { if (curMat || curMesh) {
if ( !curMat || !curMesh) { if ( !curMat || !curMesh) {
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material"); DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
releaseMaterial( &curMat ); releaseMaterial( curMat );
releaseMesh( &curMesh ); releaseMesh( curMesh );
} }
else { else {
materials.push_back(curMat); materials.push_back(curMat);