Fix T60261: Crash pasting a material without a nodetree
This commit is contained in:
parent
dfb63653f4
commit
e57ee5934a
Notes:
blender-bot
2023-02-14 05:59:31 +01:00
Referenced by issue #60885, Boolean modifier problem when multiple modifiers active on object Referenced by issue #60735, Cycles renders only first duplivert when mesh has generative modifier Referenced by issue #60667, reflection plane bug in rendered view. EEVEE Referenced by issue #60597, Material Shader Crashes Cycles Referenced by issue #60601, Crash when check cavity and shadow from shading menu. Referenced by issue #60585, 2.8 Builds are limited to 16 threads of processing Referenced by issue #60261, Crash when pasting a material in 2.79 file Referenced by issue #55026, Slow Parent option doesn't work with new Depsgraph
|
@ -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)
|
||||
|
|
|
@ -1782,6 +1782,7 @@ static int paste_material_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
|
||||
paste_matcopybuf(CTX_data_main(C), ma);
|
||||
|
||||
DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
|
||||
WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, ma);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
|
Loading…
Reference in New Issue