[Bf-blender-cvs] [d899710] id-remap: Merge branch 'missing-libs' into id-remap
Bastien Montagne
noreply at git.blender.org
Wed Oct 14 21:24:42 CEST 2015
Commit: d89971095238158838b32bcce06dfe45e38e8c37
Author: Bastien Montagne
Date: Wed Oct 14 21:10:08 2015 +0200
Branches: id-remap
https://developer.blender.org/rBd89971095238158838b32bcce06dfe45e38e8c37
Merge branch 'missing-libs' into id-remap
Huge load of conflicts, hope it did not break too much things...
Current code build, but crashes easily :|
===================================================================
===================================================================
diff --cc source/blender/blenkernel/intern/lamp.c
index 0003134,60b88b9..b9ade7d
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@@ -218,22 -218,22 +218,21 @@@ void BKE_lamp_make_local(Lamp *la
}
}
+/** Free (or release) any data used by this lamp (does not free the lamp itself). */
void BKE_lamp_free(Lamp *la)
{
- MTex *mtex;
int a;
+ BKE_animdata_free((ID *)la);
+
for (a = 0; a < MAX_MTEX; a++) {
- mtex = la->mtex[a];
- if (mtex && mtex->tex) mtex->tex->id.us--;
- if (mtex) MEM_freeN(mtex);
+ MEM_SAFE_FREE(la->mtex[a]);
}
- BKE_animdata_free((ID *)la);
-
curvemapping_free(la->curfalloff);
+ la->curfalloff = NULL;
/* is no lib link block, but lamp extension */
- /* XXX Half-broken, idremap will NULL-ify that (though setting user count to zero) :/ */
if (la->nodetree) {
ntreeFreeTree(la->nodetree);
MEM_freeN(la->nodetree);
diff --cc source/blender/blenkernel/intern/library.c
index a2a2156,d29eaee..ef64d1d
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@@ -1344,13 -1085,13 +1343,13 @@@ void BKE_libblock_free_ex(Main *bmain,
BKE_scene_free((Scene *)id);
break;
case ID_LI:
- library_free((Library *)id);
+ BKE_library_free((Library *)id);
break;
case ID_OB:
- BKE_object_free_ex((Object *)id, do_id_user);
+ BKE_object_free((Object *)id);
break;
case ID_ME:
- BKE_mesh_free((Mesh *)id, 1);
+ BKE_mesh_free((Mesh *)id);
break;
case ID_CU:
BKE_curve_free((Curve *)id);
diff --cc source/blender/blenkernel/intern/linestyle.c
index 4e863d4,d8eb8f2..61697d3
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@@ -129,16 -128,15 +129,15 @@@ FreestyleLineStyle *BKE_linestyle_new(s
void BKE_linestyle_free(FreestyleLineStyle *linestyle)
{
LineStyleModifier *m;
-
- MTex *mtex;
int a;
+ BKE_animdata_free(&linestyle->id);
+
for (a = 0; a < MAX_MTEX; a++) {
- mtex = linestyle->mtex[a];
- if (mtex && mtex->tex) mtex->tex->id.us--;
- if (mtex) MEM_freeN(mtex);
+ MEM_SAFE_FREE(linestyle->mtex[a]);
}
+
+ /* is no lib link block, but linestyle extension */
- /* XXX Half-broken, idremap will NULL-ify that (though setting user count to zero) :/ */
if (linestyle->nodetree) {
ntreeFreeTree(linestyle->nodetree);
MEM_freeN(linestyle->nodetree);
diff --cc source/blender/blenkernel/intern/material.c
index db08efe,a43906c..4589ad2
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@@ -81,34 -81,45 +81,33 @@@ void init_def_material(void
BKE_init_material(&defmaterial);
}
-/* not material itself */
+/** Free (or release) any data used by this material (does not free the 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)
-{
- MTex *mtex;
int a;
+
+ 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 */
- /* XXX Half-broken, idremap will NULL-ify that (though setting user count to zero) :/ */
if (ma->nodetree) {
- ntreeFreeTree_ex(ma->nodetree, do_id_user);
+ ntreeFreeTree(ma->nodetree);
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_free(&ma->gpumaterial);
+ BKE_icon_id_delete((ID *)ma);
+ BKE_previewimg_free(&ma->preview);
}
void BKE_init_material(Material *ma)
diff --cc source/blender/blenkernel/intern/scene.c
index 182a8a4,d4a8d29..5ebdf96
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@@ -374,21 -389,12 +374,20 @@@ void BKE_scene_free(Scene *sce
BLI_freelistN(&sce->base);
BKE_sequencer_editing_free(sce);
- BKE_animdata_free((ID *)sce);
BKE_keyingsets_free(&sce->keyingsets);
-
- if (sce->rigidbody_world)
+
+ /* is no lib link block, but scene extension */
- /* XXX Half-broken, idremap will NULL-ify that (though setting user count to zero) :/ */
+ if (sce->nodetree) {
+ ntreeFreeTree(sce->nodetree);
+ MEM_freeN(sce->nodetree);
+ sce->nodetree = NULL;
+ }
+
+ if (sce->rigidbody_world) {
BKE_rigidbody_free_world(sce->rigidbody_world);
-
+ sce->rigidbody_world = NULL;
+ }
+
if (sce->r.avicodecdata) {
free_avicodecdata(sce->r.avicodecdata);
MEM_freeN(sce->r.avicodecdata);
diff --cc source/blender/blenkernel/intern/texture.c
index 48e09d6,ab8bceb..c5622e9
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@@ -557,13 -557,19 +557,12 @@@ int colorband_element_remove(struct Col
/* ******************* TEX ************************ */
+/** Free (or release) any data used by this texture (does not free the texure itself). */
void BKE_texture_free(Tex *tex)
{
- if (tex->coba) MEM_freeN(tex->coba);
- if (tex->env) BKE_texture_envmap_free(tex->env);
- if (tex->pd) BKE_texture_pointdensity_free(tex->pd);
- if (tex->vd) BKE_texture_voxeldata_free(tex->vd);
- if (tex->ot) BKE_texture_ocean_free(tex->ot);
- BKE_animdata_free((struct ID *)tex);
-
- BKE_previewimg_free(&tex->preview);
- BKE_icon_id_delete((struct ID *)tex);
- tex->id.icon_id = 0;
-
+ BKE_animdata_free((ID *)tex);
+
+ /* is no lib link block, but texture extension */
- /* XXX Half-broken, idremap will NULL-ify that (though setting user count to zero) :/ */
if (tex->nodetree) {
ntreeFreeTree(tex->nodetree);
MEM_freeN(tex->nodetree);
diff --cc source/blender/blenkernel/intern/world.c
index 03a93be,68e15d5..e568fa0
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@@ -58,22 -58,29 +58,21 @@@ void BKE_world_free(World *wrld
BKE_animdata_free((ID *)wrld);
+ for (a = 0; a < MAX_MTEX; a++) {
+ MEM_SAFE_FREE(wrld->mtex[a]);
+ }
+
/* is no lib link block, but world extension */
- /* XXX Half-broken, idremap will NULL-ify that (though setting user count to zero) :/ */
if (wrld->nodetree) {
- ntreeFreeTree_ex(wrld->nodetree, do_id_user);
+ ntreeFreeTree(wrld->nodetree);
MEM_freeN(wrld->nodetree);
+ wrld->nodetree = NULL;
}
- if (wrld->gpumaterial.first)
- GPU_material_free(&wrld->gpumaterial);
+ GPU_material_free(&wrld->gpumaterial);
BKE_icon_id_delete((struct ID *)wrld);
- wrld->id.icon_id = 0;
-}
-
-void BKE_world_free(World *wrld)
-{
- BKE_world_free_ex(wrld, true);
+ BKE_previewimg_free(&wrld->preview);
}
void BKE_world_init(World *wrld)
diff --cc source/blender/blenloader/intern/readfile.c
index 3faf9f2,4c8bdbd..eb03ef7
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@@ -9627,8 -9615,9 +9615,8 @@@ static void give_base_to_groups
}
}
- static ID *create_placeholder(Main *mainvar, const short idcode, const char *name, const short flag)
-static ID *create_placeholder(Main *mainvar, const char *idname, const short flag)
++static ID *create_placeholder(Main *mainvar, const short idcode, const char *idname, const short flag)
{
- const short idcode = GS(idname);
ListBase *lb = which_libbase(mainvar, idcode);
ID *ph_id = BKE_libblock_alloc_notest(idcode);
@@@ -9820,9 -9800,9 +9807,9 @@@ static void link_id_part(ReportList *re
mainvar->curlib->filepath,
library_parent_filepath(mainvar->curlib));
- /* Generate a placeholder for this ID (limited version of read_libblock actually...). */
+ /* Generate a placeholder for this ID (simplified version of read_libblock actually...). */
if (r_id) {
- *r_id = create_placeholder(mainvar, GS(id->name), id->name + 2, id->flag);
- *r_id = create_placeholder(mainvar, id->name, id->flag);
++ *r_id = create_placeholder(mainvar, GS(id->name), id->name, id->flag);
}
}
}
diff --cc source/blender/makesrna/intern/rna_main_api.c
index 2b4ca24,5a0da0b..887acac
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@@ -734,7 -733,7 +734,6 @@@ static Mask *rna_Main_mask_new(Main *bm
static void rna_Main_masks_remove(Main *bmain, PointerRNA *mask_ptr)
{
Mask *mask = mask_ptr->data;
- BKE_mask_unlink(bmain, mask);
- BKE_mask_free(bmain, mask);
BKE_libblock_free(bmain, mask);
RNA_POINTER_INVALIDATE(mask_ptr);
}
More information about the Bf-blender-cvs
mailing list