Fix T60261: Crash pasting a material without a nodetree
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user