[Bf-blender-cvs] [0db98b214d4] master: Fix T81345: part four, fix handling of IDProperties in edit armature undo.

Bastien Montagne noreply at git.blender.org
Fri Oct 2 17:46:30 CEST 2020


Commit: 0db98b214d468864630fc9bba72be4ff9b2548e5
Author: Bastien Montagne
Date:   Fri Oct 2 17:38:28 2020 +0200
Branches: master
https://developer.blender.org/rB0db98b214d468864630fc9bba72be4ff9b2548e5

Fix T81345: part four, fix handling of IDProperties in edit armature undo.

Specific armature editing undo code would duplicate and store a list of
editbones. However, those are not linked to main data storage and should
therefore never affect ID usercounting.

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

M	source/blender/editors/armature/armature_utils.c
M	source/blender/editors/armature/editarmature_undo.c
M	source/blender/editors/include/ED_armature.h

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

diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index 29df8b31819..fba88e78162 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -35,6 +35,7 @@
 #include "BKE_deform.h"
 #include "BKE_global.h"
 #include "BKE_idprop.h"
+#include "BKE_lib_id.h"
 #include "BKE_main.h"
 
 #include "DEG_depsgraph.h"
@@ -847,7 +848,7 @@ void ED_armature_to_edit(bArmature *arm)
 
 /* free's bones and their properties */
 
-void ED_armature_ebone_listbase_free(ListBase *lb)
+void ED_armature_ebone_listbase_free(ListBase *lb, const bool do_id_user)
 {
   EditBone *ebone, *ebone_next;
 
@@ -855,7 +856,7 @@ void ED_armature_ebone_listbase_free(ListBase *lb)
     ebone_next = ebone->next;
 
     if (ebone->prop) {
-      IDP_FreeProperty(ebone->prop);
+      IDP_FreeProperty_ex(ebone->prop, do_id_user);
     }
 
     MEM_freeN(ebone);
@@ -864,7 +865,7 @@ void ED_armature_ebone_listbase_free(ListBase *lb)
   BLI_listbase_clear(lb);
 }
 
-void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src)
+void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src, const bool do_id_user)
 {
   EditBone *ebone_src;
   EditBone *ebone_dst;
@@ -874,7 +875,8 @@ void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src)
   for (ebone_src = lb_src->first; ebone_src; ebone_src = ebone_src->next) {
     ebone_dst = MEM_dupallocN(ebone_src);
     if (ebone_dst->prop) {
-      ebone_dst->prop = IDP_CopyProperty(ebone_dst->prop);
+      ebone_dst->prop = IDP_CopyProperty_ex(ebone_dst->prop,
+                                            do_id_user ? 0 : LIB_ID_CREATE_NO_USER_REFCOUNT);
     }
     ebone_src->temp.ebone = ebone_dst;
     BLI_addtail(lb_dst, ebone_dst);
diff --git a/source/blender/editors/armature/editarmature_undo.c b/source/blender/editors/armature/editarmature_undo.c
index bdb08abbf2c..c217b615db6 100644
--- a/source/blender/editors/armature/editarmature_undo.c
+++ b/source/blender/editors/armature/editarmature_undo.c
@@ -64,8 +64,8 @@ static void undoarm_to_editarm(UndoArmature *uarm, bArmature *arm)
 {
   EditBone *ebone;
 
-  ED_armature_ebone_listbase_free(arm->edbo);
-  ED_armature_ebone_listbase_copy(arm->edbo, &uarm->lb);
+  ED_armature_ebone_listbase_free(arm->edbo, true);
+  ED_armature_ebone_listbase_copy(arm->edbo, &uarm->lb, true);
 
   /* active bone */
   if (uarm->act_edbone) {
@@ -86,7 +86,7 @@ static void *undoarm_from_editarm(UndoArmature *uarm, bArmature *arm)
   /* TODO: include size of ID-properties. */
   uarm->undo_size = 0;
 
-  ED_armature_ebone_listbase_copy(&uarm->lb, arm->edbo);
+  ED_armature_ebone_listbase_copy(&uarm->lb, arm->edbo, false);
 
   /* active bone */
   if (arm->act_edbone) {
@@ -105,7 +105,7 @@ static void *undoarm_from_editarm(UndoArmature *uarm, bArmature *arm)
 
 static void undoarm_free_data(UndoArmature *uarm)
 {
-  ED_armature_ebone_listbase_free(&uarm->lb);
+  ED_armature_ebone_listbase_free(&uarm->lb, false);
 }
 
 static Object *editarm_object_from_context(bContext *C)
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 1eeb81d4dc7..3501acd4fdf 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -171,8 +171,10 @@ void ED_armature_from_edit(struct Main *bmain, struct bArmature *arm);
 void ED_armature_to_edit(struct bArmature *arm);
 void ED_armature_edit_free(struct bArmature *arm);
 void ED_armature_ebone_listbase_temp_clear(struct ListBase *lb);
-void ED_armature_ebone_listbase_free(struct ListBase *lb);
-void ED_armature_ebone_listbase_copy(struct ListBase *lb_dst, struct ListBase *lb_src);
+void ED_armature_ebone_listbase_free(struct ListBase *lb, const bool do_id_user);
+void ED_armature_ebone_listbase_copy(struct ListBase *lb_dst,
+                                     struct ListBase *lb_src,
+                                     const bool do_id_user);
 
 /* low level selection functions which handle */
 int ED_armature_ebone_selectflag_get(const struct EditBone *ebone);



More information about the Bf-blender-cvs mailing list