Fix #29696: Crash on exit of edit mode after deleting contents of fluid domain
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 28 Dec 2011 17:59:56 +0000 (17:59 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 28 Dec 2011 17:59:56 +0000 (17:59 +0000)
Added NULL-check to copying material number and flags when loading cache

source/blender/modifiers/intern/MOD_fluidsim_util.c

index 6541b15f66e0cf2115851d634717155b9cc989bf..0452c6a4e7360ecf5096d33b14ab4bfd4856c5bb 100644 (file)
@@ -499,16 +499,20 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim
        }
 
        // assign material + flags to new dm
+       // if there's no faces in original dm, keep materials and flags unchanged
        mface = orgdm->getFaceArray(orgdm);
-       mat_nr = mface[0].mat_nr;
-       flag = mface[0].flag;
 
-       mface = dm->getFaceArray(dm);
-       numfaces = dm->getNumFaces(dm);
-       for(i=0; i<numfaces; i++)
-       {
-               mface[i].mat_nr = mat_nr;
-               mface[i].flag = flag;
+       if(mface) {
+               mat_nr = mface[0].mat_nr;
+               flag = mface[0].flag;
+
+               mface = dm->getFaceArray(dm);
+               numfaces = dm->getNumFaces(dm);
+               for(i=0; i<numfaces; i++)
+                       {
+                               mface[i].mat_nr = mat_nr;
+                               mface[i].flag = flag;
+                       }
        }
 
        // load vertex velocities, if they exist...