ID management: Do not assume that `NO_MAIN` means `NO_USER_REFCOUNT`
While this is still very fuzzy in current code, this old behavior makes it close to impossible to efficiently use out-of-main temp data, as it implies that we'd need to update refcounts everytime we add something back into BMain (an 'un-refcount' ID usages when removing from BMain). Now that we have two separate flags/tags for those two different things, let's not merge them anymore. Note that this is somewhat on-going process, still needs more checks and cleanup. Related to T88555.
This commit is contained in:
parent
8f9599d17e
commit
ee849ca0f8
|
@ -1221,14 +1221,6 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int ori
|
|||
BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) != 0 || bmain != NULL);
|
||||
BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) != 0 || (flag & LIB_ID_CREATE_NO_ALLOCATE) == 0);
|
||||
BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) != 0 || (flag & LIB_ID_CREATE_LOCAL) == 0);
|
||||
if (!is_private_id_data) {
|
||||
/* When we are handling private ID data, we might still want to manage usercounts, even
|
||||
* though that ID data-block is actually outside of Main... */
|
||||
BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) == 0 ||
|
||||
(flag & LIB_ID_CREATE_NO_USER_REFCOUNT) != 0);
|
||||
}
|
||||
/* Never implicitly copy shapekeys when generating temp data outside of Main database. */
|
||||
BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) == 0 || (flag & LIB_ID_COPY_SHAPEKEY) == 0);
|
||||
|
||||
/* 'Private ID' data handling. */
|
||||
if ((bmain != NULL) && is_private_id_data) {
|
||||
|
|
|
@ -244,9 +244,10 @@ static void library_foreach_ID_link(Main *bmain,
|
|||
* (the node tree), but re-use those generated for the 'owner' ID (the material). */
|
||||
if (inherit_data == NULL) {
|
||||
data.cb_flag = ID_IS_LINKED(id) ? IDWALK_CB_INDIRECT_USAGE : 0;
|
||||
/* When an ID is not in Main database, it should never refcount IDs it is using.
|
||||
* Exceptions: NodeTrees (yeah!) directly used by Materials. */
|
||||
data.cb_flag_clear = (id->tag & LIB_TAG_NO_MAIN) ? IDWALK_CB_USER | IDWALK_CB_USER_ONE : 0;
|
||||
/* When an ID is defined as not refcounting its ID usages, it should never do it. */
|
||||
data.cb_flag_clear = (id->tag & LIB_TAG_NO_USER_REFCOUNT) ?
|
||||
IDWALK_CB_USER | IDWALK_CB_USER_ONE :
|
||||
0;
|
||||
}
|
||||
else {
|
||||
data.cb_flag = inherit_data->cb_flag;
|
||||
|
|
Loading…
Reference in New Issue