Fix T80104: Crash on making material local.

Problem is again with the embedded data, we want to make those local
together with their owner ID, but sometimes we are actually dealing with
copies here, which are inheritently already local.

Code did not considered that possibility before, leading to access to a
NULL `lib` pointer.

This should also be back-ported to 2.83 LTS release.

Maniphest Tasks: T80104

Differential Revision: https://developer.blender.org/D8731
This commit is contained in:
Bastien Montagne 2020-08-27 15:48:01 +02:00 committed by Jeroen Bakker
parent 812c234377
commit cbb5201f09
Notes: blender-bot 2023-02-14 03:29:37 +01:00
Referenced by issue #80104, Crash on making material local
Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
1 changed files with 5 additions and 2 deletions

View File

@ -396,8 +396,11 @@ static int lib_id_expand_local_cb(LibraryIDLinkCallbackData *cb_data)
}
if (cb_flag & IDWALK_CB_EMBEDDED) {
/* Embedded data-blocks need to be made fully local as well. */
if (*id_pointer != NULL) {
/* Embedded data-blocks need to be made fully local as well.
* Note however that in some cases (when owner ID had to be duplicated instead of being made
* local directly), its embedded IDs should also have already been duplicated, and hence be
* fully local here already. */
if (*id_pointer != NULL && ID_IS_LINKED(*id_pointer)) {
BLI_assert(*id_pointer != id_self);
lib_id_clear_library_data_ex(bmain, *id_pointer);