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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user