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:
authorBastien Montagne <montagne29@wanadoo.fr>2015-11-09 21:47:10 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-11-09 23:00:53 +0300
commit865796375bcfa6be4288cca4243dddcb4092f70b (patch)
tree5264d4b9b0f9d392b6e1b942e0f6fd802de1fff4 /source/blender/editors/object
parentcf959a879eb5ffbdfa573c5f3a00965e69d7a976 (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/editors/object')
-rw-r--r--source/blender/editors/object/object_add.c44
-rw-r--r--source/blender/editors/object/object_edit.c12
-rw-r--r--source/blender/editors/object/object_relations.c28
3 files changed, 46 insertions, 38 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 269700c3aef..2cead58300d 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1587,7 +1587,7 @@ static int convert_exec(bContext *C, wmOperator *op)
/* decrement original mesh's usage count */
me = newob->data;
- me->id.us--;
+ id_us_min(&me->id);
/* make a new copy of the mesh */
newob->data = BKE_mesh_copy(me);
@@ -1612,7 +1612,7 @@ static int convert_exec(bContext *C, wmOperator *op)
/* decrement original mesh's usage count */
me = newob->data;
- me->id.us--;
+ id_us_min(&me->id);
/* make a new copy of the mesh */
newob->data = BKE_mesh_copy(me);
@@ -1643,7 +1643,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob = basen->object;
/* decrement original curve's usage count */
- ((Curve *)newob->data)->id.us--;
+ id_us_min(&((Curve *)newob->data)->id);
/* make a new copy of the curve */
newob->data = BKE_curve_copy(ob->data);
@@ -1664,19 +1664,19 @@ static int convert_exec(bContext *C, wmOperator *op)
cu->type = OB_CURVE;
if (cu->vfont) {
- cu->vfont->id.us--;
+ id_us_min(&cu->vfont->id);
cu->vfont = NULL;
}
if (cu->vfontb) {
- cu->vfontb->id.us--;
+ id_us_min(&cu->vfontb->id);
cu->vfontb = NULL;
}
if (cu->vfonti) {
- cu->vfonti->id.us--;
+ id_us_min(&cu->vfonti->id);
cu->vfonti = NULL;
}
if (cu->vfontbi) {
- cu->vfontbi->id.us--;
+ id_us_min(&cu->vfontbi->id);
cu->vfontbi = NULL;
}
@@ -1714,7 +1714,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob = basen->object;
/* decrement original curve's usage count */
- ((Curve *)newob->data)->id.us--;
+ id_us_min(&((Curve *)newob->data)->id);
/* make a new copy of the curve */
newob->data = BKE_curve_copy(ob->data);
@@ -1749,7 +1749,7 @@ static int convert_exec(bContext *C, wmOperator *op)
newob = basen->object;
mb = newob->data;
- mb->id.us--;
+ id_us_min(&mb->id);
newob->data = BKE_mesh_add(bmain, "Mesh");
newob->type = OB_MESH;
@@ -1915,7 +1915,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
ID_NEW_US(obn->mat[a])
else
obn->mat[a] = BKE_material_copy(obn->mat[a]);
- id->us--;
+ id_us_min(id);
if (dupflag & USER_DUP_ACT) {
BKE_animdata_copy_id_action(&obn->mat[a]->id);
@@ -1936,7 +1936,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
BKE_animdata_copy_id_action(&psys->part->id);
}
- id->us--;
+ id_us_min(id);
}
}
}
@@ -1952,7 +1952,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_mesh_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_CURVE:
@@ -1962,7 +1962,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_curve_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_SURF:
@@ -1972,7 +1972,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_curve_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_FONT:
@@ -1982,7 +1982,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_curve_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_MBALL:
@@ -1992,7 +1992,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_mball_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_LAMP:
@@ -2002,7 +2002,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_lamp_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_ARMATURE:
@@ -2016,7 +2016,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
BKE_pose_rebuild(obn, obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_LATTICE:
@@ -2026,7 +2026,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_lattice_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_CAMERA:
@@ -2036,7 +2036,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_camera_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
case OB_SPEAKER:
@@ -2046,7 +2046,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
obn->data = BKE_speaker_copy(obn->data);
didit = 1;
}
- id->us--;
+ id_us_min(id);
}
break;
}
@@ -2083,7 +2083,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
ID_NEW_US((*matarar)[a])
else
(*matarar)[a] = BKE_material_copy((*matarar)[a]);
- id->us--;
+ id_us_min(id);
}
}
}
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index c87eeaeb4a3..9b7563ae729 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -934,16 +934,20 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
cu1->wordspace = cu->wordspace;
cu1->ulpos = cu->ulpos;
cu1->ulheight = cu->ulheight;
- if (cu1->vfont) cu1->vfont->id.us--;
+ if (cu1->vfont)
+ id_us_min(&cu1->vfont->id);
cu1->vfont = cu->vfont;
id_us_plus((ID *)cu1->vfont);
- if (cu1->vfontb) cu1->vfontb->id.us--;
+ if (cu1->vfontb)
+ id_us_min(&cu1->vfontb->id);
cu1->vfontb = cu->vfontb;
id_us_plus((ID *)cu1->vfontb);
- if (cu1->vfonti) cu1->vfonti->id.us--;
+ if (cu1->vfonti)
+ id_us_min(&cu1->vfonti->id);
cu1->vfonti = cu->vfonti;
id_us_plus((ID *)cu1->vfonti);
- if (cu1->vfontbi) cu1->vfontbi->id.us--;
+ if (cu1->vfontbi)
+ id_us_min(&cu1->vfontbi->id);
cu1->vfontbi = cu->vfontbi;
id_us_plus((ID *)cu1->vfontbi);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 3d030f1a770..a89ef8b7e85 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1555,7 +1555,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
switch (type) {
case MAKE_LINKS_OBDATA: /* obdata */
- obdata_id->us--;
+ id_us_min(obdata_id);
obdata_id = ob_src->data;
id_us_plus(obdata_id);
@@ -1624,16 +1624,20 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
break;
}
- if (cu_dst->vfont) cu_dst->vfont->id.us--;
+ if (cu_dst->vfont)
+ id_us_min(&cu_dst->vfont->id);
cu_dst->vfont = cu_src->vfont;
id_us_plus((ID *)cu_dst->vfont);
- if (cu_dst->vfontb) cu_dst->vfontb->id.us--;
+ if (cu_dst->vfontb)
+ id_us_min(&cu_dst->vfontb->id);
cu_dst->vfontb = cu_src->vfontb;
id_us_plus((ID *)cu_dst->vfontb);
- if (cu_dst->vfonti) cu_dst->vfonti->id.us--;
+ if (cu_dst->vfonti)
+ id_us_min(&cu_dst->vfonti->id);
cu_dst->vfonti = cu_src->vfonti;
id_us_plus((ID *)cu_dst->vfonti);
- if (cu_dst->vfontbi) cu_dst->vfontbi->id.us--;
+ if (cu_dst->vfontbi)
+ id_us_min(&cu_dst->vfontbi->id);
cu_dst->vfontbi = cu_src->vfontbi;
id_us_plus((ID *)cu_dst->vfontbi);
@@ -1758,7 +1762,7 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, const in
}
base->flag = obn->flag;
- ob->id.us--;
+ id_us_min(&ob->id);
}
}
}
@@ -1826,11 +1830,11 @@ static void new_id_matar(Material **matar, const int totcol)
if (id->newid) {
matar[a] = (Material *)id->newid;
id_us_plus(id->newid);
- id->us--;
+ id_us_min(id);
}
else if (id->us > 1) {
matar[a] = BKE_material_copy(matar[a]);
- id->us--;
+ id_us_min(id);
id->newid = (ID *)matar[a];
}
}
@@ -1912,7 +1916,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, const int flag)
*/
BKE_animdata_copy_id_action((ID *)ob->data);
- id->us--;
+ id_us_min(id);
id->newid = ob->data;
}
}
@@ -1966,7 +1970,7 @@ static void single_mat_users(Scene *scene, const int flag, const bool do_texture
for (b = 0; b < MAX_MTEX; b++) {
if (ma->mtex[b] && (tex = ma->mtex[b]->tex)) {
if (tex->id.us > 1) {
- tex->id.us--;
+ id_us_min(&tex->id);
tex = BKE_texture_copy(tex);
BKE_animdata_copy_id_action(&tex->id);
man->mtex[b]->tex = tex;
@@ -1991,13 +1995,13 @@ static void do_single_tex_user(Tex **from)
if (tex->id.newid) {
*from = (Tex *)tex->id.newid;
id_us_plus(tex->id.newid);
- tex->id.us--;
+ id_us_min(&tex->id);
}
else if (tex->id.us > 1) {
texn = BKE_texture_copy(tex);
BKE_animdata_copy_id_action(&texn->id);
tex->id.newid = (ID *)texn;
- tex->id.us--;
+ id_us_min(&tex->id);
*from = texn;
}
}