diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-11-09 21:47:10 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-11-09 23:00:53 +0300 |
commit | 865796375bcfa6be4288cca4243dddcb4092f70b (patch) | |
tree | 5264d4b9b0f9d392b6e1b942e0f6fd802de1fff4 /source/blender/blenkernel/intern/object.c | |
parent | cf959a879eb5ffbdfa573c5f3a00965e69d7a976 (diff) |
Cleanup: avoid incrementing/decrementing id->us outside of BKE_library.
We have callbacks for that, they also do some checks and help ensure things are done
correctly. Only place where this is assumed not true is blenloader (since here we
may affect refcount of library IDs as well...).
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 456791e99fc..1e345605ec2 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -40,6 +40,7 @@ #include "DNA_armature_types.h" #include "DNA_camera_types.h" #include "DNA_constraint_types.h" +#include "DNA_gpencil_types.h" #include "DNA_group_types.h" #include "DNA_key_types.h" #include "DNA_lamp_types.h" @@ -389,7 +390,7 @@ void BKE_object_free_ex(Object *ob, bool do_id_user) /* disconnect specific data, but not for lib data (might be indirect data, can get relinked) */ if (ob->data) { ID *id = ob->data; - id->us--; + id_us_min(id); if (id->us == 0 && id->lib == NULL) { switch (ob->type) { case OB_MESH: @@ -408,7 +409,8 @@ void BKE_object_free_ex(Object *ob, bool do_id_user) if (ob->mat) { for (a = 0; a < ob->totcol; a++) { - if (ob->mat[a]) ob->mat[a]->id.us--; + if (ob->mat[a]) + id_us_min(&ob->mat[a]->id); } MEM_freeN(ob->mat); } @@ -420,8 +422,10 @@ void BKE_object_free_ex(Object *ob, bool do_id_user) if (ob->bb) MEM_freeN(ob->bb); ob->bb = NULL; if (ob->adt) BKE_animdata_free((ID *)ob); - if (ob->poselib) ob->poselib->id.us--; - if (ob->gpd) ((ID *)ob->gpd)->us--; + if (ob->poselib) + id_us_min(&ob->poselib->id); + if (ob->gpd) + id_us_min(&ob->gpd->id); if (ob->defbase.first) BLI_freelistN(&ob->defbase); if (ob->pose) @@ -1656,8 +1660,8 @@ void BKE_object_make_local(Object *ob) while (base) { if (base->object == ob) { base->object = ob_new; - ob_new->id.us++; - ob->id.us--; + id_us_plus(&ob_new->id); + id_us_min(&ob->id); } base = base->next; } |