Commit: bf90fcda4760f52ea7cebcceb7dc0d0e1a7de93a
Author: Bastien Montagne
Date:   Mon Jan 11 16:41:22 2021 +0100
Branches: master
https://developer.blender.org/rBbf90fcda4760f52ea7cebcceb7dc0d0e1a7de93a

ID Creation: generate `session_uuid` in more cases.

Previous code would not generate a session uuid for embedded IDs (like
root node trees or master collections). While this is not a problem
currently since those are not directly stored in Main data-base, this is
conceptually wrong, since those IDs still pertain the Main data.

Further more, this is blocking using `session_uuid` more in depsgraph in
place from ID pointer itself, as identifier (related to T84397).

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

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

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

diff --git a/source/blender/blenkernel/intern/lib_id.c 
b/source/blender/blenkernel/intern/lib_id.c
index be7ce34f7e6..0cba26dd3d2 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -1087,8 +1087,6 @@ void *BKE_libblock_alloc(Main *bmain, short type, const 
char *name, const int fl
       /* alphabetic insertion: is in new_id */
       BKE_main_unlock(bmain);
 
-      BKE_lib_libblock_session_uuid_ensure(id);
-
       /* TODO to be removed from here! */
       if ((flag & LIB_ID_CREATE_NO_DEG_TAG) == 0) {
         DEG_id_type_tag(bmain, type);
@@ -1097,6 +1095,13 @@ void *BKE_libblock_alloc(Main *bmain, short type, const 
char *name, const int fl
     else {
       BLI_strncpy(id->name + 2, name, sizeof(id->name) - 2);
     }
+
+    /* We also need to ensure a valid `session_uuid` for some non-main data 
(like embedded IDs).
+     * IDs not allocated however should not need those (this would e.g. avoid 
generating session
+     * uuids for depsgraph CoW IDs, if it was using this function). */
+    if ((flag & LIB_ID_CREATE_NO_ALLOCATE) == 0) {
+      BKE_lib_libblock_session_uuid_ensure(id);
+    }
   }
 
   return id;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to