[Bf-blender-cvs] [35932aaf1dd] override-recursive-resync: ID management: Do not assume that `NO_MAIN` means `NO_USER_REFCOUNT`

Bastien Montagne noreply at git.blender.org
Wed May 26 18:01:30 CEST 2021


Commit: 35932aaf1dd1e3b8acea46d48e6abe00e6cb8a7b
Author: Bastien Montagne
Date:   Wed May 26 11:45:27 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rB35932aaf1dd1e3b8acea46d48e6abe00e6cb8a7b

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.

===================================================================

M	source/blender/blenkernel/intern/lib_id.c
M	source/blender/blenkernel/intern/lib_query.c

===================================================================

diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index c2e5006cbc1..8ad524dea21 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -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) {
diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c
index 3281783d81a..b748061ef8a 100644
--- a/source/blender/blenkernel/intern/lib_query.c
+++ b/source/blender/blenkernel/intern/lib_query.c
@@ -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;



More information about the Bf-blender-cvs mailing list