OpenGEX: Use std::unique_ptr to fix some memory leaks
parent
5ce9ece0cc
commit
17b26c91e2
|
@ -691,7 +691,8 @@ void OpenGEXImporter::handleTransformNode( ODDLParser::DDLNode *node, aiScene *
|
||||||
void OpenGEXImporter::handleMeshNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
void OpenGEXImporter::handleMeshNode( ODDLParser::DDLNode *node, aiScene *pScene ) {
|
||||||
m_currentMesh = new aiMesh;
|
m_currentMesh = new aiMesh;
|
||||||
const size_t meshidx( m_meshCache.size() );
|
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();
|
Property *prop = node->getProperties();
|
||||||
if( nullptr != prop ) {
|
if( nullptr != prop ) {
|
||||||
|
@ -1138,7 +1139,7 @@ void OpenGEXImporter::copyMeshes( aiScene *pScene ) {
|
||||||
pScene->mNumMeshes = static_cast<unsigned int>(m_meshCache.size());
|
pScene->mNumMeshes = static_cast<unsigned int>(m_meshCache.size());
|
||||||
pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ];
|
pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ];
|
||||||
for (unsigned int i = 0; i < pScene->mNumMeshes; i++) {
|
for (unsigned int i = 0; i < pScene->mNumMeshes; i++) {
|
||||||
pScene->mMeshes[i] = m_meshCache[i];
|
pScene->mMeshes[i] = m_meshCache[i].release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ private:
|
||||||
typedef std::map<aiNode*, std::unique_ptr<ChildInfo> > NodeChildMap;
|
typedef std::map<aiNode*, std::unique_ptr<ChildInfo> > NodeChildMap;
|
||||||
NodeChildMap m_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;
|
typedef std::map<std::string, size_t> ReferenceMap;
|
||||||
std::map<std::string, size_t> m_mesh2refMap;
|
std::map<std::string, size_t> m_mesh2refMap;
|
||||||
std::map<std::string, size_t> m_material2refMap;
|
std::map<std::string, size_t> m_material2refMap;
|
||||||
|
|
Loading…
Reference in New Issue