diff options
author | Bastien Montagne <bastien@blender.org> | 2020-10-02 18:38:28 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-10-02 18:40:51 +0300 |
commit | 0db98b214d468864630fc9bba72be4ff9b2548e5 (patch) | |
tree | 5aaef5682703c722d4827616eb160656aff05f68 /source/blender/editors | |
parent | 4b36552967bf55b1bf707acd3917280b42b12c52 (diff) |
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.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/armature/armature_utils.c | 10 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature_undo.c | 8 | ||||
-rw-r--r-- | source/blender/editors/include/ED_armature.h | 6 |
3 files changed, 14 insertions, 10 deletions
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); |