OpenGEX: Use std::unique_ptr to fix some memory leaks

pull/1775/head
Turo Lamminen 2018-02-06 20:20:16 +02:00
parent 5ce9ece0cc
commit 17b26c91e2
2 changed files with 4 additions and 3 deletions

View File

@ -691,7 +691,8 @@ void OpenGEXImporter::handleTransformNode( ODDLParser::DDLNode *node, aiScene *
void OpenGEXImporter::handleMeshNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
m_currentMesh = new aiMesh;
const size_t meshidx( m_meshCache.size() );
m_meshCache.push_back( m_currentMesh );
// ownership is transfered but a reference remains in m_currentMesh
m_meshCache.emplace_back( m_currentMesh );
Property *prop = node->getProperties();
if( nullptr != prop ) {
@ -1138,7 +1139,7 @@ void OpenGEXImporter::copyMeshes( aiScene *pScene ) {
pScene->mNumMeshes = static_cast<unsigned int>(m_meshCache.size());
pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ];
for (unsigned int i = 0; i < pScene->mNumMeshes; i++) {
pScene->mMeshes[i] = m_meshCache[i];
pScene->mMeshes[i] = m_meshCache[i].release();
}
}

View File

@ -183,7 +183,7 @@ private:
typedef std::map<aiNode*, std::unique_ptr<ChildInfo> > NodeChildMap;
NodeChildMap m_nodeChildMap;
std::vector<aiMesh*> m_meshCache;
std::vector<std::unique_ptr<aiMesh> > m_meshCache;
typedef std::map<std::string, size_t> ReferenceMap;
std::map<std::string, size_t> m_mesh2refMap;
std::map<std::string, size_t> m_material2refMap;