Material: Free gpumaterials before the notree.

This is because gpumaterials can contain references to the tree when doing lazy compilation.
This commit is contained in:
Clément Foucault 2018-03-05 00:52:19 +01:00
parent 162ef15da6
commit f14cbc0d07
1 changed files with 6 additions and 4 deletions

View File

@ -98,6 +98,9 @@ void BKE_material_free(Material *ma)
MEM_SAFE_FREE(ma->ramp_col);
MEM_SAFE_FREE(ma->ramp_spec);
/* Free gpu material before the ntree */
GPU_material_free(&ma->gpumaterial);
/* is no lib link block, but material extension */
if (ma->nodetree) {
@ -108,8 +111,6 @@ void BKE_material_free(Material *ma)
MEM_SAFE_FREE(ma->texpaintslot);
GPU_material_free(&ma->gpumaterial);
BKE_icon_id_delete((ID *)ma);
BKE_previewimg_free(&ma->preview);
}
@ -1709,13 +1710,14 @@ void paste_matcopybuf(Material *ma)
MEM_freeN(mtex);
}
/* Free gpu material before the ntree */
GPU_material_free(&ma->gpumaterial);
if (ma->nodetree) {
ntreeFreeTree(ma->nodetree);
MEM_freeN(ma->nodetree);
}
GPU_material_free(&ma->gpumaterial);
id = (ma->id);
memcpy(ma, &matcopybuf, sizeof(Material));
(ma->id) = id;