From e57ee5934a30e87410b7544ba8d18054881b2c00 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Thu, 17 Jan 2019 08:59:02 +1100 Subject: Fix T60261: Crash pasting a material without a nodetree --- source/blender/blenkernel/intern/material.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 913bc9c47e6..fc03116de20 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1399,7 +1399,10 @@ void copy_matcopybuf(Main *bmain, Material *ma) memcpy(&matcopybuf, ma, sizeof(Material)); - matcopybuf.nodetree = ntreeCopyTree_ex(ma->nodetree, bmain, false); + if (ma->nodetree != NULL) { + matcopybuf.nodetree = ntreeCopyTree_ex(ma->nodetree, bmain, false); + } + matcopybuf.preview = NULL; BLI_listbase_clear(&matcopybuf.gpumaterial); /* TODO Duplicate Engine Settings and set runtime to NULL */ @@ -1425,7 +1428,9 @@ void paste_matcopybuf(Main *bmain, Material *ma) memcpy(ma, &matcopybuf, sizeof(Material)); (ma->id) = id; - ma->nodetree = ntreeCopyTree_ex(matcopybuf.nodetree, bmain, false); + if (matcopybuf.nodetree != NULL) { + ma->nodetree = ntreeCopyTree_ex(matcopybuf.nodetree, bmain, false); + } } void BKE_material_eval(struct Depsgraph *depsgraph, Material *material) -- cgit v1.2.3