OpenGEXImporter: Store RefInfo in unique_ptr so they get automatically cleaned up

pull/1477/head
Turo Lamminen 2017-10-05 12:43:49 +03:00
parent 775f984d99
commit b841ed194b
2 changed files with 5 additions and 5 deletions

View File

@ -525,7 +525,7 @@ void OpenGEXImporter::handleObjectRefNode( DDLNode *node, aiScene *pScene ) {
m_currentNode->mNumMeshes = static_cast<unsigned int>(objRefNames.size());
m_currentNode->mMeshes = new unsigned int[ objRefNames.size() ];
if ( !objRefNames.empty() ) {
m_unresolvedRefStack.push_back( new RefInfo( m_currentNode, RefInfo::MeshRef, objRefNames ) );
m_unresolvedRefStack.push_back( std::unique_ptr<RefInfo>( new RefInfo( m_currentNode, RefInfo::MeshRef, objRefNames ) ) );
}
} else if ( m_tokenType == Grammar::LightNodeToken ) {
// TODO!
@ -544,7 +544,7 @@ void OpenGEXImporter::handleMaterialRefNode( ODDLParser::DDLNode *node, aiScene
std::vector<std::string> matRefNames;
getRefNames( node, matRefNames );
if( !matRefNames.empty() ) {
m_unresolvedRefStack.push_back( new RefInfo( m_currentNode, RefInfo::MaterialRef, matRefNames ) );
m_unresolvedRefStack.push_back( std::unique_ptr<RefInfo>( new RefInfo( m_currentNode, RefInfo::MaterialRef, matRefNames ) ) );
}
}
@ -1165,8 +1165,8 @@ void OpenGEXImporter::resolveReferences() {
}
RefInfo *currentRefInfo( nullptr );
for( std::vector<RefInfo*>::iterator it = m_unresolvedRefStack.begin(); it != m_unresolvedRefStack.end(); ++it ) {
currentRefInfo = *it;
for( auto it = m_unresolvedRefStack.begin(); it != m_unresolvedRefStack.end(); ++it ) {
currentRefInfo = it->get();
if( nullptr != currentRefInfo ) {
aiNode *node( currentRefInfo->m_node );
if( RefInfo::MeshRef == currentRefInfo->m_type ) {

View File

@ -201,7 +201,7 @@ private:
std::vector<aiCamera*> m_cameraCache;
std::vector<aiLight*> m_lightCache;
std::vector<aiNode*> m_nodeStack;
std::vector<RefInfo*> m_unresolvedRefStack;
std::vector<std::unique_ptr<RefInfo> > m_unresolvedRefStack;
};
} // Namespace OpenGEX