[Bf-blender-cvs] [c0fafa74f15] uuid-id: Some changes from review.

Bastien Montagne noreply at git.blender.org
Tue Mar 3 15:00:46 CET 2020


Commit: c0fafa74f154d490b03a4682cf6dd8e212e357d2
Author: Bastien Montagne
Date:   Tue Mar 3 15:00:04 2020 +0100
Branches: uuid-id
https://developer.blender.org/rBc0fafa74f154d490b03a4682cf6dd8e212e357d2

Some changes from review.

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

M	source/blender/blenkernel/BKE_lib_id.h
M	source/blender/blenkernel/intern/lib_id.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_250.c

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

diff --git a/source/blender/blenkernel/BKE_lib_id.h b/source/blender/blenkernel/BKE_lib_id.h
index 5b9559e36c2..3114da642e2 100644
--- a/source/blender/blenkernel/BKE_lib_id.h
+++ b/source/blender/blenkernel/BKE_lib_id.h
@@ -72,7 +72,7 @@ void BKE_libblock_init_empty(struct ID *id) ATTR_NONNULL(1);
 /* When an ID's uuid is of that value, it is unset/invalid (e.g. for runtime IDs, etc.). */
 #define MAIN_ID_SESSION_UUID_UNSET 0
 
-void BKE_lib_libblock_uuid_generate(struct ID *id);
+void BKE_lib_libblock_uuid_ensure(struct ID *id);
 
 void *BKE_id_new(struct Main *bmain, const short type, const char *name);
 void *BKE_id_new_nomain(const short type, const char *name);
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index df2146b3655..542f7db1d2e 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -954,7 +954,7 @@ void BKE_libblock_management_main_add(Main *bmain, void *idv)
   bmain->is_memfile_undo_written = false;
   BKE_main_unlock(bmain);
 
-  BKE_lib_libblock_uuid_generate(id);
+  BKE_lib_libblock_uuid_ensure(id);
 }
 
 /** Remove a data-block from given main (set it to 'NO_MAIN' status). */
@@ -1241,7 +1241,7 @@ 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_uuid_generate(id);
+      BKE_lib_libblock_uuid_ensure(id);
 
       /* TODO to be removed from here! */
       if ((flag & LIB_ID_CREATE_NO_DEG_TAG) == 0) {
@@ -1377,12 +1377,13 @@ void BKE_libblock_init_empty(ID *id)
   }
 }
 
-static uint session_uuid = 0;
 /** Generate a session-wise uuid for the given \a id. */
-void BKE_lib_libblock_uuid_generate(ID *id)
+void BKE_lib_libblock_uuid_ensure(ID *id)
 {
+  static uint global_session_uuid = 0;
+
   if (id->session_uuid == MAIN_ID_SESSION_UUID_UNSET) {
-    id->session_uuid = ++session_uuid;
+    id->session_uuid = ++global_session_uuid;
   }
 }
 
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 47e22287aca..e0498188fd5 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -8802,7 +8802,7 @@ static ID *create_placeholder(Main *mainvar, const short idcode, const char *idn
   BLI_addtail(lb, ph_id);
   id_sort_by_name(lb, ph_id, NULL);
 
-  BKE_lib_libblock_uuid_generate(ph_id);
+  BKE_lib_libblock_uuid_ensure(ph_id);
 
   return ph_id;
 }
@@ -9023,7 +9023,7 @@ static BHead *read_libblock(FileData *fd,
         id->session_uuid = MAIN_ID_SESSION_UUID_UNSET;
       }
 
-      BKE_lib_libblock_uuid_generate(id);
+      BKE_lib_libblock_uuid_ensure(id);
     }
     else {
       /* unknown ID type */
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 2ded8f09306..7ca0b07cb4f 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -446,7 +446,7 @@ static void versions_gpencil_add_main(ListBase *lb, ID *id, const char *name)
   BKE_id_new_name_validate(lb, id, name);
   /* alphabetic insertion: is in BKE_id_new_name_validate */
 
-  BKE_lib_libblock_uuid_generate(id);
+  BKE_lib_libblock_uuid_ensure(id);
 
   if (G.debug & G_DEBUG) {
     printf("Converted GPencil to ID: %s\n", id->name + 2);



More information about the Bf-blender-cvs mailing list