fix memory leak
authorwise86Android <wise86android@gmail.com>
Sun, 17 Jan 2016 14:18:12 +0000 (15:18 +0100)
committerwise86Android <wise86android@gmail.com>
Sun, 17 Jan 2016 14:18:12 +0000 (15:18 +0100)
code/SkeletonMeshBuilder.cpp
test/unit/utColladaExportLight.cpp

index 6108ac1..a3ef75b 100644 (file)
@@ -73,9 +73,11 @@ SkeletonMeshBuilder::SkeletonMeshBuilder( aiScene* pScene, aiNode* root, bool bK
     root->mMeshes[0] = 0;
 
     // create a dummy material for the mesh
-    pScene->mNumMaterials = 1;
-    pScene->mMaterials = new aiMaterial*[1];
-    pScene->mMaterials[0] = CreateMaterial();
+    if(pScene->mNumMaterials==0){
+               pScene->mNumMaterials = 1;
+               pScene->mMaterials = new aiMaterial*[1];
+               pScene->mMaterials[0] = CreateMaterial();
+    }
 }
 
 // ------------------------------------------------------------------------------------------------
index 2d6497f..5edf3e9 100644 (file)
@@ -54,7 +54,6 @@ public:
     {
         ex = new Assimp::Exporter();
         im = new Assimp::Importer();
-
     }
 
     virtual void TearDown()
@@ -73,7 +72,7 @@ protected:
 // ------------------------------------------------------------------------------------------------
 TEST_F(ColladaExportLight, testExportLight)
 {
-    const char* file = "cameraExp.dae";
+    const char* file = "lightsExp.dae";
 
     const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/lights.dae",0);
     ASSERT_TRUE(pTest!=NULL);
@@ -88,7 +87,6 @@ TEST_F(ColladaExportLight, testExportLight)
     }
 
     EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file));
-    EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada","lightsExp.dae"));
 
     const aiScene* imported = im->ReadFile(file,0);
 
@@ -123,7 +121,9 @@ TEST_F(ColladaExportLight, testExportLight)
         EXPECT_NEAR(orig->mAngleInnerCone,read->mAngleInnerCone,0.001);
         EXPECT_NEAR(orig->mAngleOuterCone,read->mAngleOuterCone,0.001);
     }
+
     delete [] origLights;
+
 }