IDManagement: Assign current Main's lib to newly created IDs.

This is mainly for doversion code, when it needs to create new IDs those
should be considered as part of the same library as the current Main's
one.

No practical changes are expected here, this is more of a general
consistency fix, and a pre-requisite for {T92333}.
This commit is contained in:
Bastien Montagne 2021-10-21 15:04:39 +02:00
parent 10fb5cc58d
commit 7681326acd
Notes: blender-bot 2023-06-26 11:58:59 +02:00
Referenced by issue #92388, Segfault crash when appending object
Referenced by issue #92333, BMain locking during the 'after liblink' doversion
1 changed files with 5 additions and 0 deletions

View File

@ -1141,6 +1141,11 @@ void *BKE_libblock_alloc(Main *bmain, short type, const char *name, const int fl
/* alphabetic insertion: is in new_id */
BKE_main_unlock(bmain);
/* This is important in 'readfile doversion after liblink' context mainly, but is a good
* consistency change in general: ID created for a Main should get that main's current
* library pointer. */
id->lib = bmain->curlib;
/* TODO: to be removed from here! */
if ((flag & LIB_ID_CREATE_NO_DEG_TAG) == 0) {
DEG_id_type_tag(bmain, type);