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

pull/1471/head
Turo Lamminen 2017-10-05 12:35:17 +03:00
parent 316046f748
commit b6d2b91799
2 changed files with 6 additions and 5 deletions

View File

@ -1231,9 +1231,9 @@ void OpenGEXImporter::pushNode( aiNode *node, aiScene *pScene ) {
if( m_nodeChildMap.end() == it ) {
info = new ChildInfo;
m_root = info;
m_nodeChildMap[ node->mParent ] = info;
m_nodeChildMap[ node->mParent ] = std::unique_ptr<ChildInfo>(info);
} else {
info = it->second;
info = it->second.get();
}
info->m_children.push_back( node );
} else {
@ -1243,9 +1243,9 @@ void OpenGEXImporter::pushNode( aiNode *node, aiScene *pScene ) {
NodeChildMap::iterator it( m_nodeChildMap.find( node->mParent ) );
if( m_nodeChildMap.end() == it ) {
info = new ChildInfo;
m_nodeChildMap[ node->mParent ] = info;
m_nodeChildMap[ node->mParent ] = std::unique_ptr<ChildInfo>(info);
} else {
info = it->second;
info = it->second.get();
}
info->m_children.push_back( node );
}

View File

@ -49,6 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <vector>
#include <list>
#include <map>
#include <memory>
namespace ODDLParser {
class DDLNode;
@ -179,7 +180,7 @@ private:
std::list<aiNode*> m_children;
};
ChildInfo *m_root;
typedef std::map<aiNode*, ChildInfo*> NodeChildMap;
typedef std::map<aiNode*, std::unique_ptr<ChildInfo> > NodeChildMap;
NodeChildMap m_nodeChildMap;
std::vector<aiMesh*> m_meshCache;