[Bf-blender-cvs] [d231260] master: Replace of (id->lib != NULL) check by meaningful macro.

Bastien Montagne noreply at git.blender.org
Wed Jul 6 14:13:13 CEST 2016


Commit: d2312602125a452e6562a76ab91779943c67396d
Author: Bastien Montagne
Date:   Wed Jul 6 14:11:01 2016 +0200
Branches: master
https://developer.blender.org/rBd2312602125a452e6562a76ab91779943c67396d

Replace of (id->lib != NULL) check by meaningful macro.

Idea is to replace hard-to-track (id->lib != NULL) 'is linked datablock' check everywhere in Blender
by a macro doing the same thing. This will allow to easily spot those checks in future, and more importantly,
to easily change it (see work done in asset-engine branch).

Note: did not touch to readfile.c, since there most of the time 'id->lib' check actually concerns the pointer,
and not a check whether ID is linked or not. Will have a closer look at it later.

Reviewers: campbellbarton, brecht, sergey

Differential Revision: https://developer.blender.org/D2082

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

M	source/blender/blenkernel/intern/action.c
M	source/blender/blenkernel/intern/armature.c
M	source/blender/blenkernel/intern/armature_update.c
M	source/blender/blenkernel/intern/bpath.c
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenkernel/intern/camera.c
M	source/blender/blenkernel/intern/constraint.c
M	source/blender/blenkernel/intern/curve.c
M	source/blender/blenkernel/intern/group.c
M	source/blender/blenkernel/intern/image.c
M	source/blender/blenkernel/intern/key.c
M	source/blender/blenkernel/intern/lamp.c
M	source/blender/blenkernel/intern/lattice.c
M	source/blender/blenkernel/intern/library.c
M	source/blender/blenkernel/intern/library_query.c
M	source/blender/blenkernel/intern/linestyle.c
M	source/blender/blenkernel/intern/mask.c
M	source/blender/blenkernel/intern/material.c
M	source/blender/blenkernel/intern/mball.c
M	source/blender/blenkernel/intern/mesh.c
M	source/blender/blenkernel/intern/modifier.c
M	source/blender/blenkernel/intern/node.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/blenkernel/intern/packedFile.c
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/speaker.c
M	source/blender/blenkernel/intern/text.c
M	source/blender/blenkernel/intern/texture.c
M	source/blender/blenkernel/intern/world.c
M	source/blender/editors/animation/anim_filter.c
M	source/blender/editors/animation/keyframes_draw.c
M	source/blender/editors/armature/pose_edit.c
M	source/blender/editors/armature/pose_lib.c
M	source/blender/editors/interface/interface_eyedropper.c
M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/interface/interface_regions.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/mesh/editmesh_tools.c
M	source/blender/editors/mesh/mesh_data.c
M	source/blender/editors/object/object_add.c
M	source/blender/editors/object/object_constraint.c
M	source/blender/editors/object/object_data_transfer.c
M	source/blender/editors/object/object_edit.c
M	source/blender/editors/object/object_modifier.c
M	source/blender/editors/object/object_relations.c
M	source/blender/editors/object/object_shapekey.c
M	source/blender/editors/object/object_transform.c
M	source/blender/editors/object/object_vgroup.c
M	source/blender/editors/physics/particle_edit.c
M	source/blender/editors/physics/particle_object.c
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/sculpt_paint/paint_image.c
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/space_logic/logic_ops.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_edit.c
M	source/blender/editors/space_outliner/outliner_tools.c
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/editors/space_text/text_ops.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/editors/space_view3d/view3d_fly.c
M	source/blender/editors/space_view3d/view3d_view.c
M	source/blender/editors/space_view3d/view3d_walk.c
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/editors/util/ed_util.c
M	source/blender/makesdna/DNA_ID.h
M	source/blender/makesrna/intern/rna_access.c
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 46ee8a4..9d6b2a0 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -107,7 +107,7 @@ static void make_localact_init_cb(ID *id, AnimData *adt, void *mlac_ptr)
 	tMakeLocalActionContext *mlac = (tMakeLocalActionContext *)mlac_ptr;
 	
 	if (adt->action == mlac->act) {
-		if (id->lib) mlac->is_lib = true;
+		if (ID_IS_LINKED_DATABLOCK(id)) mlac->is_lib = true;
 		else mlac->is_local = true;
 	}
 }
@@ -118,7 +118,7 @@ static void make_localact_apply_cb(ID *id, AnimData *adt, void *mlac_ptr)
 	tMakeLocalActionContext *mlac = (tMakeLocalActionContext *)mlac_ptr;
 	
 	if (adt->action == mlac->act) {
-		if (id->lib == NULL) {
+		if (!ID_IS_LINKED_DATABLOCK(id)) {
 			adt->action = mlac->act_new;
 			
 			id_us_plus(&mlac->act_new->id);
@@ -133,7 +133,7 @@ void BKE_action_make_local(bAction *act)
 	tMakeLocalActionContext mlac = {act, NULL, false, false};
 	Main *bmain = G.main;
 	
-	if (act->id.lib == NULL)
+	if (!ID_IS_LINKED_DATABLOCK(act))
 		return;
 	
 	/* XXX: double-check this; it used to be just single-user check, but that was when fake-users were still default */
@@ -213,7 +213,7 @@ bAction *BKE_action_copy(bAction *src)
 		}
 	}
 	
-	if (src->id.lib) {
+	if (ID_IS_LINKED_DATABLOCK(src)) {
 		BKE_id_lib_local_paths(G.main, src->id.lib, &dst->id);
 	}
 
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index b59618f..572490f 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -148,7 +148,7 @@ void BKE_armature_make_local(bArmature *arm)
 	bool is_local = false, is_lib = false;
 	Object *ob;
 
-	if (arm->id.lib == NULL)
+	if (!ID_IS_LINKED_DATABLOCK(arm))
 		return;
 	if (arm->id.us == 1) {
 		id_clear_lib_data(bmain, &arm->id);
@@ -157,7 +157,7 @@ void BKE_armature_make_local(bArmature *arm)
 
 	for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) {
 		if (ob->data == arm) {
-			if (ob->id.lib)
+			if (ID_IS_LINKED_DATABLOCK(ob))
 				is_lib = true;
 			else
 				is_local = true;
@@ -176,7 +176,7 @@ void BKE_armature_make_local(bArmature *arm)
 
 		for (ob = bmain->object.first; ob; ob = ob->id.next) {
 			if (ob->data == arm) {
-				if (ob->id.lib == NULL) {
+				if (!ID_IS_LINKED_DATABLOCK(ob)) {
 					ob->data = arm_new;
 					id_us_plus(&arm_new->id);
 					id_us_min(&arm->id);
@@ -231,7 +231,7 @@ bArmature *BKE_armature_copy(bArmature *arm)
 	newArm->act_edbone = NULL;
 	newArm->sketch = NULL;
 
-	if (arm->id.lib) {
+	if (ID_IS_LINKED_DATABLOCK(arm)) {
 		BKE_id_lib_local_paths(G.main, arm->id.lib, &newArm->id);
 	}
 
diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c
index 826bb12..ece1733 100644
--- a/source/blender/blenkernel/intern/armature_update.c
+++ b/source/blender/blenkernel/intern/armature_update.c
@@ -696,7 +696,7 @@ void BKE_pose_eval_flush(EvaluationContext *UNUSED(eval_ctx),
 
 void BKE_pose_eval_proxy_copy(EvaluationContext *UNUSED(eval_ctx), Object *ob)
 {
-	BLI_assert(ob->id.lib != NULL && ob->proxy_from != NULL);
+	BLI_assert(ID_IS_LINKED_DATABLOCK(ob) && ob->proxy_from != NULL);
 	DEBUG_PRINT("%s on %s\n", __func__, ob->id.name);
 	if (BKE_pose_copy_result(ob->pose, ob->proxy_from->pose) == false) {
 		printf("Proxy copy error, lib Object: %s proxy Object: %s\n",
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index 76544e5..a708c59 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -424,7 +424,7 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
 {
 	const char *absbase = (flag & BKE_BPATH_TRAVERSE_ABS) ? ID_BLEND_PATH(bmain, id) : NULL;
 
-	if ((flag & BKE_BPATH_TRAVERSE_SKIP_LIBRARY) && id->lib) {
+	if ((flag & BKE_BPATH_TRAVERSE_SKIP_LIBRARY) && ID_IS_LINKED_DATABLOCK(id)) {
 		return;
 	}
 
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 44cacff..4a5be1d 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -195,7 +195,7 @@ Brush *BKE_brush_copy(Brush *brush)
 	/* enable fake user by default */
 	id_fake_user_set(&brush->id);
 
-	if (brush->id.lib) {
+	if (ID_IS_LINKED_DATABLOCK(brush)) {
 		BKE_id_lib_local_paths(G.main, brush->id.lib, &brushn->id);
 	}
 
@@ -237,7 +237,7 @@ void BKE_brush_make_local(Brush *brush)
 	Scene *scene;
 	bool is_local = false, is_lib = false;
 
-	if (brush->id.lib == NULL) return;
+	if (!ID_IS_LINKED_DATABLOCK(brush)) return;
 
 	if (brush->clone.image) {
 		/* special case: ima always local immediately. Clone image should only
@@ -248,7 +248,7 @@ void BKE_brush_make_local(Brush *brush)
 
 	for (scene = bmain->scene.first; scene && ELEM(0, is_lib, is_local); scene = scene->id.next) {
 		if (BKE_paint_brush(&scene->toolsettings->imapaint.paint) == brush) {
-			if (scene->id.lib) is_lib = true;
+			if (ID_IS_LINKED_DATABLOCK(scene)) is_lib = true;
 			else is_local = true;
 		}
 	}
@@ -269,7 +269,7 @@ void BKE_brush_make_local(Brush *brush)
 		
 		for (scene = bmain->scene.first; scene; scene = scene->id.next) {
 			if (BKE_paint_brush(&scene->toolsettings->imapaint.paint) == brush) {
-				if (scene->id.lib == NULL) {
+				if (!ID_IS_LINKED_DATABLOCK(scene)) {
 					BKE_paint_brush_set(&scene->toolsettings->imapaint.paint, brush_new);
 				}
 			}
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index eabee74..9fd2c2d 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -99,7 +99,7 @@ Camera *BKE_camera_copy(Camera *cam)
 
 	id_lib_extern((ID *)camn->dof_ob);
 
-	if (cam->id.lib) {
+	if (ID_IS_LINKED_DATABLOCK(cam)) {
 		BKE_id_lib_local_paths(G.main, cam->id.lib, &camn->id);
 	}
 
@@ -117,7 +117,7 @@ void BKE_camera_make_local(Camera *cam)
 	 * - mixed: make copy
 	 */
 	
-	if (cam->id.lib == NULL) return;
+	if (!ID_IS_LINKED_DATABLOCK(cam)) return;
 	if (cam->id.us == 1) {
 		id_clear_lib_data(bmain, &cam->id);
 		return;
@@ -125,7 +125,7 @@ void BKE_camera_make_local(Camera *cam)
 	
 	for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) {
 		if (ob->data == cam) {
-			if (ob->id.lib) is_lib = true;
+			if (ID_IS_LINKED_DATABLOCK(ob)) is_lib = true;
 			else is_local = true;
 		}
 	}
@@ -143,7 +143,7 @@ void BKE_camera_make_local(Camera *cam)
 
 		for (ob = bmain->object.first; ob; ob = ob->id.next) {
 			if (ob->data == cam) {
-				if (ob->id.lib == NULL) {
+				if (!ID_IS_LINKED_DATABLOCK(ob)) {
 					ob->data = cam_new;
 					id_us_plus(&cam_new->id);
 					id_us_min(&cam->id);
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index c88b24a..4c9ddd4 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -4649,7 +4649,7 @@ void BKE_constraints_id_loop(ListBase *conlist, ConstraintIDFunc func, void *use
 /* helper for BKE_constraints_copy(), to be used for making sure that ID's are valid */
 static void con_extern_cb(bConstraint *UNUSED(con), ID **idpoin, bool UNUSED(is_reference), void *UNUSED(userData))
 {
-	if (*idpoin && (*idpoin)->lib)
+	if (*idpoin && ID_IS_LINKED_DATABLOCK(*idpoin))
 		id_lib_extern(*idpoin);
 }
 
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index c52b0f6..face3ae 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -207,7 +207,7 @@ Curve *BKE_curve_copy(Curve *cu)
 	id_us_plus((ID *)cun->vfonti);
 	id_us_plus((ID *)cun->vfontbi);
 
-	if (cu->id.lib) {
+	if (ID_IS_LINKED_DATABLOCK(cu)) {
 		BKE_id_lib_local_paths(G.main, cu->id.lib, &cun->id);
 	}
 
@@ -237,7 +237,7 @@ void BKE_curve_make_local(Curve *cu)
 	 * - mixed: do a copy
 	 */
 
-	if (cu->id.lib == NULL)
+	if (!ID_IS_LINKED_DATABLOCK(cu))
 		return;
 
 	if (cu->id.us == 1) {
@@ -248,7 +248,7 @@ void BKE_curve_make_local(Curve *cu)
 
 	for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) {
 		if (ob->data == cu) {
-			if (ob->id.lib) is_lib = true;
+			if (ID_IS_LINKED_DATABLOCK(ob)) is_lib = true;
 			else is_local = true;
 		}
 	}
@@ -265,7 +265,7 @@ void BKE_curve_make_local(Curve *cu)
 
 		for (ob = bmain->object.first; ob; ob = ob->id.next) {
 			if (ob->data == cu) {
-				if (ob->id.lib == NULL) {
+				if (!ID_IS_LINKED_DATABLOCK(ob)) {
 					ob->data = cu_new;
 					id_us_plus(&cu_new->id);
 					id_us_min(&cu->id);
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 4fdee7e..ce7ef1f 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -97,7 +97,7 @@ Group *BKE_group_copy(Group *group)
 	/* Do not copy group's preview (same behavior as for objects). */
 	groupn->preview = NULL;
 
-	if (group->id.lib) {
+	if (ID_IS_LINKED_DATABLOCK(group)) {
 		BKE_id_lib_local_paths(G.main, group->id.lib, &groupn->id);
 	}
 
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 69384a7..790b6c6 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -457,7 +457,7 @@ Image *BKE_image_copy(Main *bmain, Image *ima)
 	nima->stereo3d_format = MEM_dupallocN(ima->stereo3d_format);
 	BLI_duplicatelist(&nima->views, &ima->views);
 
-	if (ima->id.lib) {
+	if (ID_IS_LINKED_DATABLOCK(ima)) {
 		BKE_id_lib_local_paths(bmain, ima->id.lib, &nima->id);
 	}
 
@@ -483,7 +483,7 @@ void BKE_image_make_local(struct Image *ima)
 	 * - mixed: make copy
 	 */
 
-	if (ima->id.lib == NULL) return;
+	if (!ID_IS_LINKED_DATABLOCK(ima)) return;
 
 	/* Can't take short cut here: must check meshes at least because of bogus
 	 * texface ID refs. - z0r */
@@ -497,13 +497,13 @@ void BKE_image_make_local(struct Image *ima)
 
 	for (tex = bmain->tex.first; tex; tex = tex->id.next) {
 		if (

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list