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-10-13 16:44:58 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-10-13 16:44:58 +0300
commit168604ecbe60ba909e3057cadf1c4047ea966d0c (patch)
treea4699c125b9ace4e1d4efaff747a3ac0faed78c3 /source/blender/blenkernel/intern/material.c
parent9d5cdf92b28217e29b6840eae8d0c44f033e3cf6 (diff)
Revert to master - those changes are globally valid, but remain incomplete,free-refcount-ids
and total new code is being done in id-remap anyway, not worth bothering with this for now...
Diffstat (limited to 'source/blender/blenkernel/intern/material.c')
-rw-r--r--source/blender/blenkernel/intern/material.c65
1 files changed, 28 insertions, 37 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 300485c2c0a..3e7e98b4a1d 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -81,54 +81,45 @@ void init_def_material(void)
init_material(&defmaterial);
}
-/**
- * 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)
+/* not material itself */
+void BKE_material_free(Material *ma)
{
- 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_material_free_ex(ma, true);
+}
- BKE_animdata_free((ID *)ma);
+/* not material itself */
+void BKE_material_free_ex(Material *ma, bool do_id_user)
+{
+ MTex *mtex;
+ int a;
for (a = 0; a < MAX_MTEX; a++) {
- MEM_SAFE_FREE(ma->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->ramp_col);
- MEM_SAFE_FREE(ma->ramp_spec);
+ 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;
/* is no lib link block, but material extension */
if (ma->nodetree) {
- ntreeFreeTree(ma->nodetree, do_id_user);
+ ntreeFreeTree_ex(ma->nodetree, do_id_user);
MEM_freeN(ma->nodetree);
- ma->nodetree = NULL;
}
- MEM_SAFE_FREE(ma->texpaintslot);
-
- GPU_material_free(&ma->gpumaterial);
+ if (ma->texpaintslot)
+ MEM_freeN(ma->texpaintslot);
- BKE_icon_id_delete((ID *)ma);
- BKE_previewimg_free(&ma->preview);
+ if (ma->gpumaterial.first)
+ GPU_material_free(&ma->gpumaterial);
}
void init_material(Material *ma)
@@ -1766,7 +1757,7 @@ void free_matcopybuf(void)
matcopybuf.ramp_spec = NULL;
if (matcopybuf.nodetree) {
- ntreeFreeTree(matcopybuf.nodetree, false);
+ ntreeFreeTree_ex(matcopybuf.nodetree, false);
MEM_freeN(matcopybuf.nodetree);
matcopybuf.nodetree = NULL;
}
@@ -1816,7 +1807,7 @@ void paste_matcopybuf(Material *ma)
}
if (ma->nodetree) {
- ntreeFreeTree(ma->nodetree, true); /* XXX Or do_id_user? */
+ ntreeFreeTree(ma->nodetree);
MEM_freeN(ma->nodetree);
}