fix [#30839] Blender crashes while open/close a scene and deletes .blend-file
authorCampbell Barton <ideasman42@gmail.com>
Tue, 10 Apr 2012 13:10:44 +0000 (13:10 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 10 Apr 2012 13:10:44 +0000 (13:10 +0000)
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Ketsji/BL_Material.cpp
source/gameengine/Ketsji/BL_Material.h
source/gameengine/Ketsji/KX_BlenderMaterial.cpp

index a49a84a327d988839ed2013c5f7b911a013a958e..e112537d0f6d33a82149a3356b0746701c34694b 100644 (file)
@@ -892,7 +892,12 @@ bool ConvertMaterial(
        if (validmat)
                material->matname       =(mat->id.name);
 
-       material->tface         = tface;
+       if (tface) {
+               material->tface         = *tface;
+       }
+       else {
+               memset(&material->tface, 0, sizeof(material->tface));
+       }
        material->material      = mat;
        return true;
 }
index 2061a7633319f52bc9d6c6679fc072e62a49cb7b..4c7518769e1a28872ad23f844218e6c2923c3d04 100644 (file)
@@ -58,7 +58,7 @@ void BL_Material::Initialize()
        alpha = 1.f;
        emit = 0.f;
        material = 0;
-       tface = 0;
+       memset(&tface, 0, sizeof(tface));
        materialindex = 0;
        amb=0.5f;
        num_enabled = 0;
index 7b1779fed109e71224d78c448e8d8c3e1ac369ed..70fd640a07e06a360c80b5933ced451a54e578fe 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "STR_String.h"
 #include "MT_Point2.h"
+#include "DNA_meshdata_types.h"
 
 #ifdef WITH_CXX_GUARDEDALLOC
 #include "MEM_guardedalloc.h"
@@ -83,7 +84,7 @@ public:
 
 
        Material*                       material;
-       MTFace*                         tface;
+       MTFace                          tface; /* copy of the derived meshes tface */
        Image*                          img[MAXTEX];
        EnvMap*                         cubemap[MAXTEX];
 
index 13727be8b98469abce93eaab165b2d63926c781c..018a8d44cc18531852a6b93b67b4550007e8c550 100644 (file)
@@ -118,8 +118,7 @@ KX_BlenderMaterial::~KX_BlenderMaterial()
 MTFace* KX_BlenderMaterial::GetMTFace(void) const 
 {
        // fonts on polys
-       MT_assert(mMaterial->tface);
-       return mMaterial->tface;
+       return &mMaterial->tface;
 }
 
 unsigned int* KX_BlenderMaterial::GetMCol(void) const 
@@ -238,9 +237,7 @@ void KX_BlenderMaterial::OnExit()
        /* used to call with 'mMaterial->tface' but this can be a freed array,
         * see: [#30493], so just call with NULL, this is best since it clears
         * the 'lastface' pointer in GPU too - campbell */
-       if (mMaterial->tface) {
-               GPU_set_tpage(NULL, 1, mMaterial->alphablend);
-       }
+       GPU_set_tpage(NULL, 1, mMaterial->alphablend);
 }