[Bf-blender-cvs] [fc32567cdaa] master: Versioning: fix vertex group name loss in linked duplicates.

Alexander Gavrilov noreply at git.blender.org
Sun Jul 18 18:11:31 CEST 2021


Commit: fc32567cdaa57b39312fbea0ea217612d3543034
Author: Alexander Gavrilov
Date:   Sun Jul 18 11:47:59 2021 +0300
Branches: master
https://developer.blender.org/rBfc32567cdaa57b39312fbea0ea217612d3543034

Versioning: fix vertex group name loss in linked duplicates.

After rB3b6ee8cee708 by @HooglyBoogly vertex groups were moved
to mesh data, and versioning code was provided to upgrade old
files. However, it fails to consider the case of linked duplicates
having different name lists, and dependent on the object order
can cause some of the names to be lost. This can even be all of
them, if there is a duplicate without any names, which can be
easily created by lazy Python code.

To fix this, change the code to use the longest available name list.

Differential Revision: https://developer.blender.org/D11958

===================================================================

M	source/blender/blenloader/intern/versioning_300.c

===================================================================

diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 313ce734bbc..07a324181af 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -99,9 +99,15 @@ static void move_vertex_group_names_to_object_data(Main *bmain)
     if (ELEM(object->type, OB_MESH, OB_LATTICE, OB_GPENCIL)) {
       ListBase *new_defbase = BKE_object_defgroup_list_mutable(object);
 
-      /* Clear the list in case the it was already assigned from another object. */
-      BLI_freelistN(new_defbase);
-      *new_defbase = object->defbase;
+      /* Choose the longest vertex group name list among all linked duplicates. */
+      if (BLI_listbase_count(&object->defbase) < BLI_listbase_count(new_defbase)) {
+        BLI_freelistN(&object->defbase);
+      }
+      else {
+        /* Clear the list in case the it was already assigned from another object. */
+        BLI_freelistN(new_defbase);
+        *new_defbase = object->defbase;
+      }
     }
   }
 }



More information about the Bf-blender-cvs mailing list