[Bf-blender-cvs] [6f5aacb6d97] temp-T78835: Allows to preserve UUIDs on copy, outside of copy-on-write

Sergey Sharybin noreply at git.blender.org
Thu Jul 30 15:44:36 CEST 2020


Commit: 6f5aacb6d9734d696622001de3392f07635e84c1
Author: Sergey Sharybin
Date:   Thu Jul 30 12:44:51 2020 +0200
Branches: temp-T78835
https://developer.blender.org/rB6f5aacb6d9734d696622001de3392f07635e84c1

Allows to preserve UUIDs on copy, outside of copy-on-write

Could be useful for clipboard implementation where, for example, strips
live outside of any reachable database. The UUID will be generated on
paste, so there is no need to generate new UUID on copy.

While generating UUID is almost harmless, incrementing global counter
increases chance of overflowing the integer sooner.

This changes makes it possible to solve issue when user opens .blend
file with strips, which will generated UUIDs in the lower part of the
integer, and then holds Ctrl-C for a very long time.

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

M	source/blender/blenkernel/BKE_lib_id.h
M	source/blender/blenkernel/intern/sequencer.c

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

diff --git a/source/blender/blenkernel/BKE_lib_id.h b/source/blender/blenkernel/BKE_lib_id.h
index 3ea60ce0264..6f11b71b4ca 100644
--- a/source/blender/blenkernel/BKE_lib_id.h
+++ b/source/blender/blenkernel/BKE_lib_id.h
@@ -127,13 +127,19 @@ enum {
   LIB_ID_COPY_LOCALIZE = LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT |
                          LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW | LIB_ID_COPY_CACHES,
 
+  /* Preserve session UUIDs when doing copy.
+   * Is used by aras dependency graph, or clipboard where placing something to the clipboard does
+   * not need to generate new UUIDs because objects are out of any database and hence no need to
+   * increment UUID counter. */
+  LIB_ID_COPY_KEEP_SESSION_UUID = (1 << 27),
+
   /* Copying of the ID is requested by the dependency graph's Copy-on_Write mechanism.
    * In this case some data will be shared between original and copied datablocks. For example:
    * - Session UUIDs are not re-generated, which makes the dependency graph possible to match
    *   original and copied data, preserving runtime caches.
    * - Physics caches are shared between original and copied datablocks, avoiding duplicate of
    *   the entire cache to appear multiple times in memory. */
-  LIB_ID_COPY_ON_WRITE = (1 << 27),
+  LIB_ID_COPY_ON_WRITE = (LIB_ID_COPY_KEEP_SESSION_UUID),
 };
 
 void BKE_libblock_copy_ex(struct Main *bmain,
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 56cd1793484..f02bdcbb417 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -5672,10 +5672,7 @@ static Sequence *seq_dupli(const Scene *scene_src,
 {
   Sequence *seqn = MEM_dupallocN(seq);
 
-  if (flag & LIB_ID_COPY_ON_WRITE) {
-    /* Keep existing UUID, so that the dependency graph can match copy with the original. */
-  }
-  else {
+  if ((flag & LIB_ID_COPY_KEEP_SESSION_UUID) == 0) {
     BKE_sequence_session_uuid_generate(seq);
   }



More information about the Bf-blender-cvs mailing list