Fix #108495: Pasting a material crashes (back-port from main) #108567

Closed
Campbell Barton wants to merge 1 commits from ideasman42:pr-material-clipboard-paste-backport into blender-v3.6-release

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

1 Commits

Author SHA1 Message Date
Campbell Barton 098feaf7bf Fix #108495: Pasting a material crashes
References to data-blocks in a material were stored in-memory and could
crash if the data-blocks referenced by the material no longer existed
when pasting.

Resolve by using a blend-file for material copy/paste, matching how the
clipboard works in the 3D view-port.

Currently there is no support for including indirectly linked
data-blocks when pasting the material. Instead, data-blocks are restored
by name, by inspecting the current file.

This also fixes a crash where the `SpaceNode::nodetree` could point to
freed memory when pasting a material.

Ref !108496.

Includes contributions by @mont29.

---

Fix back-ported to main [0], including fix [1].

[0]: 5177e2f20b
[1]: 64aa96d421
2023-06-03 21:06:46 +10:00