diff options
author | Bastien Montagne <bastien@blender.org> | 2020-07-06 17:21:41 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-07-06 17:55:38 +0300 |
commit | ee3eba902a0b5d5f44b1cb2ff52a3a42cc9e9670 (patch) | |
tree | 8e6e50a808e6e29a6bb3f44b953912764e1452e6 /source/blender/blenloader | |
parent | bfc644dcfb52b873ad7c356cf4b05208fba17bba (diff) |
Runtime cache preservation during undo: add support for nodes and embedded IDs.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readblenentry.c | 12 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 29 |
2 files changed, 5 insertions, 36 deletions
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index e4129282a68..cb2094d050f 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -390,12 +390,6 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, blo_make_old_idmap_from_main(fd, old_mainlist.first); } - /* TODO: Move handling of nodetree caches to new system as well... */ - /* makes lookup of existing images in old main */ - blo_make_image_pointer_map(fd, oldmain); - /* makes lookup of existing video clips in old main */ - blo_make_movieclip_pointer_map(fd, oldmain); - /* removed packed data from this trick - it's internal data that needs saves */ /* Store all existing ID caches pointers into a mapping, to allow restoring them into newly @@ -407,12 +401,6 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, /* Ensure relinked caches are not freed together with their old IDs. */ blo_cache_storage_old_bmain_clear(fd, oldmain); - /* TODO: Move handling of nodetree caches to new system as well... */ - /* ensures relinked images are not freed */ - blo_end_image_pointer_map(fd, oldmain); - /* ensures relinked movie clips are not freed */ - blo_end_movieclip_pointer_map(fd, oldmain); - /* Still in-use libraries have already been moved from oldmain to new mainlist, * but oldmain itself shall *never* be 'transferred' to new mainlist! */ BLI_assert(old_mainlist.first == oldmain); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 441421c8736..b8ded36b4eb 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2349,7 +2349,7 @@ void blo_cache_storage_init(FileData *fd, Main *bmain) if (ID_IS_LINKED(id)) { continue; } - type_info->foreach_cache(id, blo_cache_storage_entry_register, fd->cache_storage); + BKE_idtype_id_foreach_cache(id, blo_cache_storage_entry_register, fd->cache_storage); } FOREACH_MAIN_LISTBASE_ID_END; } @@ -2379,7 +2379,7 @@ void blo_cache_storage_old_bmain_clear(FileData *fd, Main *bmain_old) if (ID_IS_LINKED(id)) { continue; } - type_info->foreach_cache(id, blo_cache_storage_entry_clear_in_old, fd->cache_storage); + BKE_idtype_id_foreach_cache(id, blo_cache_storage_entry_clear_in_old, fd->cache_storage); } FOREACH_MAIN_LISTBASE_ID_END; } @@ -3851,28 +3851,8 @@ static void direct_link_nodetree(BlendDataReader *reader, bNodeTree *ntree) BLO_read_data_address(reader, &link->tosock); } -#if 0 - if (ntree->previews) { - bNodeInstanceHash* new_previews = BKE_node_instance_hash_new("node previews"); - bNodeInstanceHashIterator iter; - - NODE_INSTANCE_HASH_ITER(iter, ntree->previews) { - bNodePreview* preview = BKE_node_instance_hash_iterator_get_value(&iter); - if (preview) { - bNodePreview* new_preview = newimaadr(fd, preview); - if (new_preview) { - bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter); - BKE_node_instance_hash_insert(new_previews, key, new_preview); - } - } - } - BKE_node_instance_hash_free(ntree->previews, NULL); - ntree->previews = new_previews; - } -#else - /* XXX TODO */ + /* TODO, should be dealt by new generic cache handling of IDs... */ ntree->previews = NULL; -#endif /* type verification is in lib-link */ } @@ -9242,7 +9222,8 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID * /* try to restore (when undoing) or clear ID's cache pointers. */ if (id_type->foreach_cache != NULL) { - id_type->foreach_cache(id, blo_cache_storage_entry_restore_in_new, reader.fd->cache_storage); + BKE_idtype_id_foreach_cache( + id, blo_cache_storage_entry_restore_in_new, reader.fd->cache_storage); } return success; |