diff options
author | Bastien Montagne <b.mont29@gmail.com> | 2020-03-05 18:17:14 +0300 |
---|---|---|
committer | Bastien Montagne <b.mont29@gmail.com> | 2020-03-05 18:30:12 +0300 |
commit | c43725e1891bd8534ac4b668277cddae9762d524 (patch) | |
tree | 59e26be9adb639b82305ce0f6f4dc36490052f06 /source/blender/blenloader | |
parent | 88db9a17ce70c4553be1922e3ecef091e8c1d039 (diff) |
Add an session-wise uuid integer to IDs.
"session-wise" here mean while editing a same .blend file. So creating
or opening a new one will reset the uuid counter. This should avoid any
overflow in practice.
Only IDs added to Main database get an uuid, runtime-only ones are not
affected.
This is intended to provide undo with a way to find IDs across several
'memory realms' (undo speedup project).
No behavior change is expected from this commit itself.
Part of T60695.
Differential Revision: https://developer.blender.org/D7007
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 13 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_250.c | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 3107de38ff7..4d46435eea0 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8056,7 +8056,8 @@ void blo_lib_link_restore(Main *oldmain, Scene *curscene, ViewLayer *cur_view_layer) { - struct IDNameLib_Map *id_map = BKE_main_idmap_create(newmain, true, oldmain); + struct IDNameLib_Map *id_map = BKE_main_idmap_create( + newmain, true, oldmain, MAIN_IDMAP_TYPE_NAME); for (WorkSpace *workspace = newmain->workspaces.first; workspace; workspace = workspace->id.next) { @@ -8801,6 +8802,8 @@ 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_session_uuid_ensure(ph_id); + return ph_id; } @@ -9013,6 +9016,14 @@ static BHead *read_libblock(FileData *fd, oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code); BLI_addtail(lb, id); + + if (fd->memfile == NULL) { + /* When actually reading a file , we do want to reset/re-generate session uuids. + * In unod case, we want to re-use existing ones. */ + id->session_uuid = MAIN_ID_SESSION_UUID_UNSET; + } + + BKE_lib_libblock_session_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 a4b51f91be4..cf4924eeb6d 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -446,6 +446,8 @@ 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_session_uuid_ensure(id); + if (G.debug & G_DEBUG) { printf("Converted GPencil to ID: %s\n", id->name + 2); } |