diff --git a/code/AssetLib/Irr/IRRLoader.cpp b/code/AssetLib/Irr/IRRLoader.cpp index 89a30b263..d463bc69c 100644 --- a/code/AssetLib/Irr/IRRLoader.cpp +++ b/code/AssetLib/Irr/IRRLoader.cpp @@ -1328,7 +1328,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy // Now merge all sub scenes and attach them to the correct // attachment points in the scenegraph. - SceneCombiner::MergeScenes(&pScene, tempScene, attach, + SceneCombiner::MergeScenes(&pScene, tempScene.release(), attach, AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES | (!configSpeedFlag ? (AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY | AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES) : 0)); diff --git a/code/AssetLib/LWS/LWSLoader.cpp b/code/AssetLib/LWS/LWSLoader.cpp index a866cfe18..8650564ce 100644 --- a/code/AssetLib/LWS/LWSLoader.cpp +++ b/code/AssetLib/LWS/LWSLoader.cpp @@ -906,7 +906,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy flipper.Execute(master.get()); // OK ... finally build the output graph - SceneCombiner::MergeScenes(&pScene, master, attach, + SceneCombiner::MergeScenes(&pScene, master.release(), attach, AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES | (!configSpeedFlag ? ( AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY | AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES) : 0)); diff --git a/code/AssetLib/MD3/MD3Loader.cpp b/code/AssetLib/MD3/MD3Loader.cpp index 0f0bfac3a..3bc864458 100644 --- a/code/AssetLib/MD3/MD3Loader.cpp +++ b/code/AssetLib/MD3/MD3Loader.cpp @@ -617,7 +617,7 @@ bool MD3Importer::ReadMultipartFile() { scene_upper->mRootNode->mTransformation = aiMatrix4x4(); // and merge the scenes - SceneCombiner::MergeScenes(&mScene, master, attach, + SceneCombiner::MergeScenes(&mScene, master.release(), attach, AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES | AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES | AI_INT_MERGE_SCENE_RESOLVE_CROSS_ATTACHMENTS | diff --git a/code/Common/SceneCombiner.cpp b/code/Common/SceneCombiner.cpp index ceff2087a..4d799f53f 100644 --- a/code/Common/SceneCombiner.cpp +++ b/code/Common/SceneCombiner.cpp @@ -200,7 +200,7 @@ void SceneCombiner::MergeScenes(aiScene **_dest, std::vector &src, un } // 'master' will be deleted afterwards - MergeScenes(_dest, master, srcList, flags); + MergeScenes(_dest, master.release(), srcList, flags); } // ------------------------------------------------------------------------------------------------ @@ -250,7 +250,8 @@ void SceneCombiner::AttachToGraph(aiScene *master, std::vector& master, std::vector &srcList, unsigned int flags) { +void SceneCombiner::MergeScenes(aiScene **_dest, aiScene *master, std::vector &srcList, unsigned int flags) { + std::unique_ptr masterAutoPtr(master); if (nullptr == _dest) { return; } @@ -258,9 +259,9 @@ void SceneCombiner::MergeScenes(aiScene **_dest, std::unique_ptr& maste // 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.get()); + SceneCombiner::CopySceneFlat(_dest, master); } else - *_dest = master.release(); + *_dest = masterAutoPtr.release(); return; } if (*_dest) { @@ -272,7 +273,7 @@ void SceneCombiner::MergeScenes(aiScene **_dest, std::unique_ptr& maste aiScene *dest = *_dest; std::vector src(srcList.size() + 1); - src[0].scene = master.release(); + src[0].scene = masterAutoPtr.release(); for (unsigned int i = 0; i < srcList.size(); ++i) { src[i + 1] = SceneHelper(srcList[i].scene); } @@ -608,7 +609,7 @@ void SceneCombiner::MergeScenes(aiScene **_dest, std::unique_ptr& maste } // Now build the output graph - AttachToGraph(master.get(), nodes); + AttachToGraph(master, nodes); dest->mRootNode = master->mRootNode; // Check whether we succeeded at building the output graph