fix [#35914] Blender crashes when trying to use vertex selection masking on a copy...
authorCampbell Barton <ideasman42@gmail.com>
Sun, 30 Jun 2013 22:04:03 +0000 (22:04 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 30 Jun 2013 22:04:03 +0000 (22:04 +0000)
source/blender/blenkernel/intern/mesh.c
source/blender/blenloader/intern/readfile.c

index 9070e253d452c5425a3e26fef0444182e46c272d..4ec86cbac7b3c1e13dce64501c379f91809cbd42 100644 (file)
@@ -517,9 +517,9 @@ Mesh *BKE_mesh_copy_ex(Main *bmain, Mesh *me)
                }
        }
 
-       men->mselect = NULL;
        men->edit_btmesh = NULL;
 
+       men->mselect = MEM_dupallocN(men->mselect);
        men->bb = MEM_dupallocN(men->bb);
        
        men->key = BKE_key_copy(me->key);
@@ -3938,10 +3938,7 @@ int BKE_mesh_mselect_active_get(Mesh *me, int type)
 {
        BLI_assert(ELEM3(type, ME_VSEL, ME_ESEL, ME_FSEL));
 
-       /* XXX how can it be that sometimes me->mselect is NULL here ? 
-          It happens, but its not clear why it happens! 
-       */
-       if (me->totselect && me->mselect) {
+       if (me->totselect) {
                if (me->mselect[me->totselect - 1].type == type) {
                        return me->mselect[me->totselect - 1].index;
                }
index 673cd3f7b2630d661b73dc99a9a473698a568576..5d30bf6ff738cfa315e7cee25ef897d6e465df15 100644 (file)
@@ -4148,6 +4148,11 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
        mesh->bb = NULL;
        mesh->edit_btmesh = NULL;
        
+       /* happens with old files */
+       if (mesh->mselect == NULL) {
+               mesh->totselect = 0;
+       }
+
        /* Multires data */
        mesh->mr= newdataadr(fd, mesh->mr);
        if (mesh->mr) {