Fix T55427: Removing Vertex Group used by Data Transfer Modifier results in crash.
authorBastien Montagne <montagne29@wanadoo.fr>
Sat, 16 Jun 2018 14:19:53 +0000 (16:19 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Sat, 16 Jun 2018 14:22:00 +0000 (16:22 +0200)
Only fixing crash, proper handling (a.k.a remapping) of all
possible cases here, for all possible data layers, is rather involved...

source/blender/blenkernel/intern/deform.c

index 22ff8bf4bb713bfb82ec494516fef3db7cbc8b27..f33f17019b3d78554f9ec14cc13b7a2f8108f153 100644 (file)
@@ -1189,7 +1189,12 @@ bool data_transfer_layersmapping_vgroups(
 
                if (fromlayers >= 0) {
                        idx_src = fromlayers;
-                       BLI_assert(idx_src < BLI_listbase_count(&ob_src->defbase));
+                       if (idx_src >= BLI_listbase_count(&ob_src->defbase)) {
+                               /* This can happen when vgroups are removed from source object...
+                                * Remapping would be really tricky here, we'd need to go over all objects in Main everytime we delete
+                                * a vgroup... for now, simpler and safer to abort. */
+                               return false;
+                       }
                }
                else if ((idx_src = ob_src->actdef - 1) == -1) {
                        return false;