Fix memory leak
parent
d3ee157342
commit
ca781a5860
|
@ -1258,7 +1258,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
batch.LoadAll();
|
||||
|
||||
// Allocate a temporary scene data structure
|
||||
aiScene *tempScene = new aiScene();
|
||||
std::unique_ptr<aiScene> tempScene(new aiScene());
|
||||
tempScene->mRootNode = new aiNode();
|
||||
tempScene->mRootNode->mName.Set("<IRRRoot>");
|
||||
|
||||
|
|
|
@ -854,7 +854,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
|
||||
// and build the final output graph by attaching the loaded external
|
||||
// files to ourselves. first build a master graph
|
||||
aiScene *master = new aiScene();
|
||||
std::unique_ptr<aiScene> master(new aiScene());
|
||||
aiNode *nd = master->mRootNode = new aiNode();
|
||||
|
||||
// allocate storage for cameras&lights
|
||||
|
@ -899,11 +899,11 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
|
||||
// convert the master scene to RH
|
||||
MakeLeftHandedProcess monster_cheat;
|
||||
monster_cheat.Execute(master);
|
||||
monster_cheat.Execute(master.get());
|
||||
|
||||
// .. ccw
|
||||
FlipWindingOrderProcess flipper;
|
||||
flipper.Execute(master);
|
||||
flipper.Execute(master.get());
|
||||
|
||||
// OK ... finally build the output graph
|
||||
SceneCombiner::MergeScenes(&pScene, master, attach,
|
||||
|
|
|
@ -554,7 +554,7 @@ bool MD3Importer::ReadMultipartFile() {
|
|||
batch.LoadAll();
|
||||
|
||||
// now construct a dummy scene to place these three parts in
|
||||
aiScene *master = new aiScene();
|
||||
std::unique_ptr<aiScene> master(new aiScene());
|
||||
aiNode *nd = master->mRootNode = new aiNode();
|
||||
nd->mName.Set("<MD3_Player>");
|
||||
|
||||
|
@ -633,7 +633,6 @@ bool MD3Importer::ReadMultipartFile() {
|
|||
delete scene_upper;
|
||||
delete scene_lower;
|
||||
delete scene_head;
|
||||
delete master;
|
||||
|
||||
if (failure == mod_filename) {
|
||||
throw DeadlyImportError("MD3: failure to read multipart host file");
|
||||
|
|
|
@ -190,7 +190,7 @@ void SceneCombiner::MergeScenes(aiScene **_dest, std::vector<aiScene *> &src, un
|
|||
*_dest = new aiScene();
|
||||
|
||||
// Create a dummy scene to serve as master for the others
|
||||
aiScene *master = new aiScene();
|
||||
std::unique_ptr<aiScene> master(new aiScene());
|
||||
master->mRootNode = new aiNode();
|
||||
master->mRootNode->mName.Set("<MergeRoot>");
|
||||
|
||||
|
@ -250,7 +250,7 @@ void SceneCombiner::AttachToGraph(aiScene *master, std::vector<NodeAttachmentInf
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void SceneCombiner::MergeScenes(aiScene **_dest, aiScene *master, std::vector<AttachmentInfo> &srcList, unsigned int flags) {
|
||||
void SceneCombiner::MergeScenes(aiScene **_dest, std::unique_ptr<aiScene>& master, std::vector<AttachmentInfo> &srcList, unsigned int flags) {
|
||||
if (nullptr == _dest) {
|
||||
return;
|
||||
}
|
||||
|
@ -258,9 +258,9 @@ void SceneCombiner::MergeScenes(aiScene **_dest, aiScene *master, std::vector<At
|
|||
// if _dest points to nullptr allocate a new scene. Otherwise clear the old and reuse it
|
||||
if (srcList.empty()) {
|
||||
if (*_dest) {
|
||||
SceneCombiner::CopySceneFlat(_dest, master);
|
||||
SceneCombiner::CopySceneFlat(_dest, master.get());
|
||||
} else
|
||||
*_dest = master;
|
||||
*_dest = master.release();
|
||||
return;
|
||||
}
|
||||
if (*_dest) {
|
||||
|
@ -272,7 +272,7 @@ void SceneCombiner::MergeScenes(aiScene **_dest, aiScene *master, std::vector<At
|
|||
aiScene *dest = *_dest;
|
||||
|
||||
std::vector<SceneHelper> src(srcList.size() + 1);
|
||||
src[0].scene = master;
|
||||
src[0].scene = master.release();
|
||||
for (unsigned int i = 0; i < srcList.size(); ++i) {
|
||||
src[i + 1] = SceneHelper(srcList[i].scene);
|
||||
}
|
||||
|
@ -608,7 +608,7 @@ void SceneCombiner::MergeScenes(aiScene **_dest, aiScene *master, std::vector<At
|
|||
}
|
||||
|
||||
// Now build the output graph
|
||||
AttachToGraph(master, nodes);
|
||||
AttachToGraph(master.get(), nodes);
|
||||
dest->mRootNode = master->mRootNode;
|
||||
|
||||
// Check whether we succeeded at building the output graph
|
||||
|
|
|
@ -223,7 +223,7 @@ public:
|
|||
* deletes the input scenes afterwards. There may be duplicate scenes.
|
||||
* @param flags Combination of the AI_INT_MERGE_SCENE flags defined above
|
||||
*/
|
||||
static void MergeScenes(aiScene **dest, aiScene *master,
|
||||
static void MergeScenes(aiScene **dest, std::unique_ptr<aiScene>& master,
|
||||
std::vector<AttachmentInfo> &src,
|
||||
unsigned int flags = 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue