[Bf-blender-cvs] [4181f35] missing-libs: Handling missing libs: changed idea, now adding 'real' empty data.

Bastien Montagne noreply at git.blender.org
Wed Jul 15 20:46:14 CEST 2015


Commit: 4181f350147fd328e8dd76f3e7cf8cc6688f7099
Author: Bastien Montagne
Date:   Mon Jul 6 17:01:36 2015 +0200
Branches: missing-libs
https://developer.blender.org/rB4181f350147fd328e8dd76f3e7cf8cc6688f7099

Handling missing libs: changed idea, now adding 'real' empty data.

Just having 'NULL' data as placeholder is not really possible, too much places
to check against that.

WIP commit, still much to be done!

See T43351 for details.

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

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

M	source/blender/blenkernel/BKE_brush.h
M	source/blender/blenkernel/BKE_curve.h
M	source/blender/blenkernel/BKE_library.h
M	source/blender/blenkernel/BKE_mesh.h
M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/BKE_scene.h
M	source/blender/blenkernel/intern/action.c
M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenkernel/intern/armature.c
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenkernel/intern/camera.c
M	source/blender/blenkernel/intern/curve.c
M	source/blender/blenkernel/intern/image.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/material.c
M	source/blender/blenkernel/intern/mball.c
M	source/blender/blenkernel/intern/mesh.c
M	source/blender/blenkernel/intern/node.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenkernel/intern/speaker.c
M	source/blender/blenkernel/intern/texture.c
M	source/blender/blenkernel/intern/world.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/space_outliner/outliner_tools.c

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

diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index 042fba7..ca2aa74 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -40,6 +40,7 @@ void BKE_brush_system_init(void);
 void BKE_brush_system_exit(void);
 
 /* datablock functions */
+void BKE_brush_init(struct Brush *brush);
 struct Brush *BKE_brush_add(struct Main *bmain, const char *name);
 struct Brush *BKE_brush_copy(struct Brush *brush);
 void BKE_brush_make_local(struct Brush *brush);
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index a03dd28..061270b 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -69,6 +69,7 @@ typedef struct CurveCache {
 void BKE_curve_unlink(struct Curve *cu);
 void BKE_curve_free(struct Curve *cu);
 void BKE_curve_editfont_free(struct Curve *cu);
+void BKE_curve_init(struct Curve *cu);
 struct Curve *BKE_curve_add(struct Main *bmain, const char *name, int type);
 struct Curve *BKE_curve_copy(struct Curve *cu);
 void BKE_curve_make_local(struct Curve *cu);
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index e78713f..218deb5 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -47,8 +47,9 @@ struct bContext;
 struct PointerRNA;
 struct PropertyRNA;
 
-struct ID *BKE_liblock_alloc_notest(short type);
+void *BKE_libblock_alloc_notest(short type);
 void *BKE_libblock_alloc(struct Main *bmain, short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+void  BKE_libblock_init_empty(struct ID *id);
 void *BKE_libblock_copy_ex(struct Main *bmain, struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 void *BKE_libblock_copy_nolib(struct ID *id, const bool do_action) ATTR_NONNULL();
 void *BKE_libblock_copy(struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 1ff2c6b..8337dc4 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -81,6 +81,7 @@ int BKE_mesh_edge_other_vert(const struct MEdge *e, int v);
 
 void BKE_mesh_unlink(struct Mesh *me);
 void BKE_mesh_free(struct Mesh *me, int unlink);
+void BKE_mesh_init(struct Mesh *me);
 struct Mesh *BKE_mesh_add(struct Main *bmain, const char *name);
 struct Mesh *BKE_mesh_copy_ex(struct Main *bmain, struct Mesh *me);
 struct Mesh *BKE_mesh_copy(struct Mesh *me);
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 9482ec7..3a9c5fd 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -85,6 +85,7 @@ bool BKE_object_is_in_editmode(struct Object *ob);
 bool BKE_object_is_in_editmode_vgroup(struct Object *ob);
 bool BKE_object_is_in_wpaint_select_vert(struct Object *ob);
 
+void BKE_object_init(struct Object *ob);
 struct Object *BKE_object_add_only_object(
         struct Main *bmain,
         int type, const char *name)
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 027bdbb..aa69831 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -67,6 +67,7 @@ void free_avicodecdata(struct AviCodecData *acd);
 void free_qtcodecdata(struct QuicktimeCodecData *acd);
 
 void BKE_scene_free(struct Scene *sce);
+void BKE_scene_init(struct Scene *sce);
 struct Scene *BKE_scene_add(struct Main *bmain, const char *name);
 
 /* base functions */
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 4c6bd82..1b73978 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -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) || ID_MISSING(&act->id))
+	if (act->id.lib == NULL)
 		return;
 	
 	/* XXX: double-check this; it used to be just single-user check, but that was when fake-users were still default */
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 3eb1399..d5a8b8f 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -82,7 +82,7 @@
 bool id_type_can_have_animdata(ID *id)
 {
 	/* sanity check */
-	if ((id == NULL) || ID_MISSING(id))
+	if (id == NULL)
 		return false;
 
 	/* Only some ID-blocks have this info for now */
@@ -126,9 +126,8 @@ AnimData *BKE_animdata_from_id(ID *id)
 		IdAdtTemplate *iat = (IdAdtTemplate *)id;
 		return iat->adt;
 	}
-	else {
+	else
 		return NULL;
-	}
 }
 
 /* Add AnimData to the given ID-block. In order for this to work, we assume that 
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index c058f87..27d3d1c 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -139,7 +139,7 @@ void BKE_armature_make_local(bArmature *arm)
 	bool is_local = false, is_lib = false;
 	Object *ob;
 
-	if ((arm->id.lib == NULL) || ID_MISSING(&arm->id))
+	if (arm->id.lib == NULL)
 		return;
 	if (arm->id.us == 1) {
 		id_clear_lib_data(bmain, &arm->id);
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 32dc5fe..a8b1919 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -131,12 +131,8 @@ static void brush_defaults(Brush *brush)
 
 /* Datablock add/copy/free/make_local */
 
-Brush *BKE_brush_add(Main *bmain, const char *name)
+void BKE_brush_init(Brush *brush)
 {
-	Brush *brush;
-
-	brush = BKE_libblock_alloc(bmain, ID_BR, name);
-
 	/* enable fake user by default */
 	brush->id.flag |= LIB_FAKEUSER;
 
@@ -146,6 +142,15 @@ Brush *BKE_brush_add(Main *bmain, const char *name)
 
 	/* the default alpha falloff curve */
 	BKE_brush_curve_preset(brush, CURVE_PRESET_SMOOTH);
+}
+
+Brush *BKE_brush_add(Main *bmain, const char *name)
+{
+	Brush *brush;
+
+	brush = BKE_libblock_alloc(bmain, ID_BR, name);
+
+	BKE_brush_init(brush);
 
 	return brush;
 }
@@ -223,8 +228,7 @@ void BKE_brush_make_local(Brush *brush)
 	Scene *scene;
 	bool is_local = false, is_lib = false;
 
-	if ((brush->id.lib == NULL) || ID_MISSING(&brush->id))
-		return;
+	if (brush->id.lib == NULL) return;
 
 	if (brush->clone.image) {
 		/* special case: ima always local immediately. Clone image should only
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index fe1a3de..b308dc7 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -108,9 +108,7 @@ void BKE_camera_make_local(Camera *cam)
 	 * - mixed: make copy
 	 */
 	
-	if ((cam->id.lib == NULL) || ID_MISSING(&cam->id))
-		return;
-
+	if (cam->id.lib == NULL) return;
 	if (cam->id.us == 1) {
 		id_clear_lib_data(bmain, &cam->id);
 		return;
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index da9cff2..8ea0f73 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -161,15 +161,12 @@ void BKE_curve_free(Curve *cu)
 		MEM_freeN(cu->tb);
 }
 
-Curve *BKE_curve_add(Main *bmain, const char *name, int type)
+void BKE_curve_init(Curve *cu)
 {
-	Curve *cu;
-
-	cu = BKE_libblock_alloc(bmain, ID_CU, name);
 	copy_v3_fl(cu->size, 1.0f);
 	cu->flag = CU_FRONT | CU_BACK | CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS;
 	cu->pathlen = 100;
-	cu->resolu = cu->resolv = (type == OB_SURF) ? 4 : 12;
+	cu->resolu = cu->resolv = (cu->type == OB_SURF) ? 4 : 12;
 	cu->width = 1.0;
 	cu->wordspace = 1.0;
 	cu->spacing = cu->linedist = 1.0;
@@ -179,7 +176,6 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
 	cu->smallcaps_scale = 0.75f;
 	/* XXX: this one seems to be the best one in most cases, at least for curve deform... */
 	cu->twist_mode = CU_TWIST_MINIMUM;
-	cu->type = type;
 	cu->bevfac1 = 0.0f;
 	cu->bevfac2 = 1.0f;
 	cu->bevfac1_mapping = CU_BEVFAC_MAP_RESOLU;
@@ -187,7 +183,7 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
 
 	cu->bb = BKE_boundbox_alloc_unit();
 
-	if (type == OB_FONT) {
+	if (cu->type == OB_FONT) {
 		cu->vfont = cu->vfontb = cu->vfonti = cu->vfontbi = BKE_vfont_builtin_get();
 		cu->vfont->id.us += 4;
 		cu->str = MEM_mallocN(12, "str");
@@ -198,6 +194,16 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
 		cu->tb = MEM_callocN(MAXTEXTBOX * sizeof(TextBox), "textbox");
 		cu->tb[0].w = cu->tb[0].h = 0.0;
 	}
+}
+
+Curve *BKE_curve_add(Main *bmain, const char *name, int type)
+{
+	Curve *cu;
+
+	cu = BKE_libblock_alloc(bmain, ID_CU, name);
+	cu->type = type;
+
+	BKE_curve_init(cu);
 
 	return cu;
 }
@@ -267,7 +273,7 @@ void BKE_curve_make_local(Curve *cu)
 	 * - mixed: do a copy
 	 */
 
-	if ((cu->id.lib == NULL) || ID_MISSING(&cu->id))
+	if (cu->id.lib == NULL)
 		return;
 
 	if (cu->id.us == 1) {
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index f752774..ef760f2 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -477,8 +477,7 @@ void BKE_image_make_local(struct Image *ima)
 	 * - mixed: make copy
 	 */
 
-	if ((ima->id.lib == NULL) || ID_MISSING(&ima->id))
-		return;
+	if (ima->id.lib == NULL) return;
 
 	/* Can't take short cut here: must check meshes at least because of bogus
 	 * texface ID refs. - z0r */
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
index 9b46415..44e35c6 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -170,9 +170,7 @@ void BKE_lamp_make_local(Lamp *la)
 	 * - mixed: make copy
 	 */
 	
-	if ((la->id.lib == NULL) || ID_MISSING(&la->id))
-		return;
-
+	if (la->id.lib == NULL) return;
 	if (la->id.us == 1) {
 		id_clear_lib_data(bmain, &la->id);
 		return;
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/bl

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list