diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-03-05 02:52:19 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-03-06 18:44:04 +0300 |
commit | f14cbc0d0773d33f917c75f84b25dbc1e48a2976 (patch) | |
tree | f56d9409a3f19a4445e1c65db519e2d0475bd3e7 /source/blender/blenkernel/intern | |
parent | 162ef15da6da4027ce59ef0b93d3234524d1cdf8 (diff) |
Material: Free gpumaterials before the notree.
This is because gpumaterials can contain references to the tree when doing lazy compilation.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 0117cfcc022..87a57e2973a 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -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; |