Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2021-07-18 11:47:59 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2021-07-18 19:09:56 +0300
commitfc32567cdaa57b39312fbea0ea217612d3543034 (patch)
tree2cd4b0544b580b9640b8f3af1e0cfb32b611210d
parent9eafdb985d4b45a441164ff86a212a4cc6b29a09 (diff)
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
-rw-r--r--source/blender/blenloader/intern/versioning_300.c12
1 files changed, 9 insertions, 3 deletions
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;
+ }
}
}
}