[Bf-blender-cvs] [a219728] missing-libs: Merge branch 'free-refcount-ids' into missing-libs
Bastien Montagne
noreply at git.blender.org
Thu Oct 8 12:14:04 CEST 2015
Commit: a219728914f36c3cf1df8b10767f623662989977
Author: Bastien Montagne
Date: Thu Oct 8 12:13:28 2015 +0200
Branches: missing-libs
https://developer.blender.org/rBa219728914f36c3cf1df8b10767f623662989977
Merge branch 'free-refcount-ids' into missing-libs
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_curve.h
index 061270b,17836ce..4ac5629
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@@ -66,10 -66,8 +66,9 @@@ typedef struct CurveCache
#define CU_DO_2DFILL(cu) ((((cu)->flag & CU_3D) == 0) && (((cu)->flag & (CU_FRONT | CU_BACK)) != 0))
/* ** Curve ** */
- void BKE_curve_unlink(struct Curve *cu);
- void BKE_curve_free(struct Curve *cu);
+ void BKE_curve_free(struct Curve *cu, const bool do_id_user);
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 --cc source/blender/blenkernel/BKE_font.h
index 5dcc6f8,0c96107..ad34e77
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@@ -78,8 -78,7 +78,8 @@@ bool BKE_vfont_is_builtin(struct VFont
void BKE_vfont_builtin_register(void *mem, int size);
void BKE_vfont_free_data(struct VFont *vfont);
- void BKE_vfont_free(struct VFont *sc);
+ void BKE_vfont_free(struct VFont *sc, const bool do_id_user);
+void BKE_vfont_init(struct VFont *vfont);
struct VFont *BKE_vfont_builtin_get(void);
struct VFont *BKE_vfont_load(struct Main *bmain, const char *filepath);
struct VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char *filepath, bool *r_exists);
diff --cc source/blender/blenkernel/BKE_lattice.h
index 828a40d,adf37c6..d4fa9af
--- a/source/blender/blenkernel/BKE_lattice.h
+++ b/source/blender/blenkernel/BKE_lattice.h
@@@ -45,10 -45,9 +45,10 @@@ struct BPoint
struct MDeformVert;
void BKE_lattice_resize(struct Lattice *lt, int u, int v, int w, struct Object *ltOb);
+void BKE_lattice_init(struct Lattice *lt);
struct Lattice *BKE_lattice_add(struct Main *bmain, const char *name);
struct Lattice *BKE_lattice_copy(struct Lattice *lt);
- void BKE_lattice_free(struct Lattice *lt);
+ void BKE_lattice_free(struct Lattice *lt, const bool do_id_user);
void BKE_lattice_make_local(struct Lattice *lt);
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du);
diff --cc source/blender/blenkernel/BKE_linestyle.h
index e3eead4,8d6a860..76e64d4
--- a/source/blender/blenkernel/BKE_linestyle.h
+++ b/source/blender/blenkernel/BKE_linestyle.h
@@@ -49,9 -49,8 +49,9 @@@ struct Object
struct ColorBand;
struct bContext;
+void BKE_linestyle_init(struct FreestyleLineStyle *linestyle);
FreestyleLineStyle *BKE_linestyle_new(struct Main *bmain, const char *name);
- void BKE_linestyle_free(FreestyleLineStyle *linestyle);
+ void BKE_linestyle_free(FreestyleLineStyle *linestyle, const bool do_id_user);
FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, FreestyleLineStyle *linestyle);
FreestyleLineStyle *BKE_linestyle_active_from_scene(struct Scene *scene);
diff --cc source/blender/blenkernel/BKE_material.h
index b85f9e5,6804838..22b71be
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@@ -45,11 -45,10 +45,10 @@@ struct Scene
/* materials */
void init_def_material(void);
- void BKE_material_free(struct Material *sc);
- void BKE_material_free_ex(struct Material *ma, bool do_id_user);
+ void BKE_material_free(struct Material *ma, const bool do_id_user);
void test_object_materials(struct Main *bmain, struct ID *id);
void BKE_material_resize_object(struct Object *ob, const short totcol, bool do_id_user);
-void init_material(struct Material *ma);
+void BKE_init_material(struct Material *ma);
void BKE_material_remap_object(struct Object *ob, const unsigned int *remap);
struct Material *BKE_material_add(struct Main *bmain, const char *name);
struct Material *BKE_material_copy(struct Material *ma);
diff --cc source/blender/blenkernel/BKE_mball.h
index 0574b88,02c5328..b09d815
--- a/source/blender/blenkernel/BKE_mball.h
+++ b/source/blender/blenkernel/BKE_mball.h
@@@ -38,9 -38,7 +38,8 @@@ struct Object
struct Scene;
struct MetaElem;
- void BKE_mball_unlink(struct MetaBall *mb);
- void BKE_mball_free(struct MetaBall *mb);
+ void BKE_mball_free(struct MetaBall *mb, const bool do_id_user);
+void BKE_mball_init(struct MetaBall *mb);
struct MetaBall *BKE_mball_add(struct Main *bmain, const char *name);
struct MetaBall *BKE_mball_copy(struct MetaBall *mb);
diff --cc source/blender/blenkernel/BKE_mesh.h
index 4c52ae8,805c562..0674aaa
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@@ -80,9 -80,7 +80,8 @@@ int poly_get_adj_loops_from_vert
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_free(struct Mesh *me, const bool do_id_user);
+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 --cc source/blender/blenkernel/BKE_scene.h
index aa69831,a18c1e7..14c7ace
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@@ -66,8 -66,7 +66,8 @@@ struct Base *_setlooper_base_step(struc
void free_avicodecdata(struct AviCodecData *acd);
void free_qtcodecdata(struct QuicktimeCodecData *acd);
- void BKE_scene_free(struct Scene *sce);
+ void BKE_scene_free(struct Scene *sce, const bool do_id_user);
+void BKE_scene_init(struct Scene *sce);
struct Scene *BKE_scene_add(struct Main *bmain, const char *name);
/* base functions */
diff --cc source/blender/blenkernel/BKE_text.h
index 50e4fa4,6350563..71a6a7d
--- a/source/blender/blenkernel/BKE_text.h
+++ b/source/blender/blenkernel/BKE_text.h
@@@ -41,10 -41,9 +41,10 @@@ struct Main
struct Text;
struct TextLine;
- void BKE_text_free (struct Text *text);
+ void BKE_text_free (struct Text *text, const bool do_id_user);
void txt_set_undostate (int u);
int txt_get_undostate (void);
+void BKE_text_init(struct Text *ta);
struct Text *BKE_text_add (struct Main *bmain, const char *name);
int txt_extended_ascii_as_utf8(char **str);
bool BKE_text_reload(struct Text *text);
diff --cc source/blender/blenkernel/BKE_world.h
index 8d7ab23,a77a5b0..7d3c56f
--- a/source/blender/blenkernel/BKE_world.h
+++ b/source/blender/blenkernel/BKE_world.h
@@@ -36,9 -36,7 +36,8 @@@
struct Main;
struct World;
- void BKE_world_free(struct World *sc);
- void BKE_world_free_ex(struct World *sc, bool do_id_user);
+ void BKE_world_free(struct World *sc, const bool do_id_user);
+void BKE_world_init(struct World *wrld);
struct World *add_world(struct Main *bmian, const char *name);
struct World *BKE_world_copy(struct World *wrld);
struct World *localize_world(struct World *wrld);
diff --cc source/blender/blenkernel/intern/curve.c
index 8eed1f4,e01813e..ce1392c
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@@ -146,25 -161,19 +161,18 @@@ void BKE_curve_free(Curve *cu, const bo
BKE_curve_editfont_free(cu);
BKE_curve_editNurb_free(cu);
- BKE_curve_unlink(cu);
- BKE_animdata_free((ID *)cu);
- if (cu->mat)
- MEM_freeN(cu->mat);
- if (cu->str)
- MEM_freeN(cu->str);
- if (cu->strinfo)
- MEM_freeN(cu->strinfo);
- if (cu->bb)
- MEM_freeN(cu->bb);
- if (cu->tb)
- MEM_freeN(cu->tb);
+ MEM_SAFE_FREE(cu->mat);
+ MEM_SAFE_FREE(cu->str);
+ MEM_SAFE_FREE(cu->strinfo);
+ MEM_SAFE_FREE(cu->bb);
+ MEM_SAFE_FREE(cu->tb);
}
-Curve *BKE_curve_add(Main *bmain, const char *name, int type)
+void BKE_curve_init(Curve *cu)
{
- Curve *cu;
+ BLI_assert(MEMCMP_NULL_STRUCT_OFS(cu, id));
- 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;
diff --cc source/blender/blenkernel/intern/material.c
index a43906c,300485c..4cff6d4
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@@ -78,54 -78,61 +78,63 @@@ Material defmaterial
/* called on startup, creator.c */
void init_def_material(void)
{
- init_material(&defmaterial);
+ BKE_init_material(&defmaterial);
}
- /* not material itself */
- void BKE_material_free(Material *ma)
- {
- BKE_material_free_ex(ma, true);
- }
-
- /* not material itself */
- void BKE_material_free_ex(Material *ma, bool do_id_user)
+ /**
+ * Free (or release) any data used by this material (does not free the material itself).
+ *
+ * \param ma The material to free.
+ * \param do_id_user When \a true, ID datablocks used (referenced) by this material are 'released'
+ * (their user count is decreased).
+ */
+ void BKE_material_free(Material *ma, const bool do_id_user)
{
- MTex *mtex;
int a;
+
+ if (do_id_user) {
+ MTex *mtex;
+
+ for (a = 0; a < MAX_MTEX; a++) {
+ mtex = ma->mtex[a];
+ if (mtex && mtex->tex) {
+ id_us_min(&mtex->tex->id);
+ mtex->tex = NULL;
+ }
+ }
+
+ /* No ID refcount here... */
+ ma->group = NULL;
+ }
+
+ BKE_animdata_free((ID *)ma);
for (a = 0; a < MAX_MTEX; a++) {
- mtex = ma->mtex[a];
- if (do_id_user && mtex && mtex->tex) mtex->tex->id.us--;
- if (mtex) MEM_freeN(mtex);
+ MEM_SAFE_FREE(ma->mtex[a]);
}
- if (ma->ramp_col) MEM_freeN(ma->ramp_col);
- if (ma->ramp_spec) MEM_freeN(ma->ramp_spec);
-
- BKE_animdata_free((ID *)ma);
-
- if (ma->preview)
- BKE_previewimg_free(&ma->preview);
- BKE_icon_id_delete((struct ID *)ma);
- ma->id.icon_id = 0;
+ MEM_SAFE_FREE(ma->ramp_col);
+ MEM_SAFE_FREE(ma->ramp_spec);
/* is no lib link block, but material extension */
if (ma->nodetree) {
- ntreeFreeTree_ex(ma->nodetree, do_id_user);
+ ntreeFreeTree(ma->nodetree, do_id_user);
MEM_freeN(ma->nodetree);
+ ma->nodetree = NULL;
}
- if (ma->texpaintslot)
- MEM_freeN(ma->texpaintslot);
+ MEM_SAFE_FREE(ma->texpaintslot);
+
+ GPU_material_free(&ma->gpumaterial);
- if (ma->gpumaterial.first)
- GPU_material
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list