From c27d00cde08ab32718af326f6b72ccfdf3ef073a Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 11 Sep 2020 11:57:54 +0200 Subject: Refactor: move CacheFile .blend I/O to IDTypeInfo callbacks --- source/blender/blenloader/intern/readfile.c | 37 ++-------------------------- source/blender/blenloader/intern/writefile.c | 21 +--------------- 2 files changed, 3 insertions(+), 55 deletions(-) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index d1dfee0e779..b0f0a08651c 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2537,28 +2537,6 @@ static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBas /** \} */ -/* -------------------------------------------------------------------- */ -/** \name Read ID: CacheFiles - * \{ */ - -static void lib_link_cachefiles(BlendLibReader *UNUSED(reader), CacheFile *UNUSED(cache_file)) -{ -} - -static void direct_link_cachefile(BlendDataReader *reader, CacheFile *cache_file) -{ - BLI_listbase_clear(&cache_file->object_paths); - cache_file->handle = NULL; - cache_file->handle_filepath[0] = '\0'; - cache_file->handle_readers = NULL; - - /* relink animdata */ - BLO_read_data_address(reader, &cache_file->adt); - BKE_animdata_blend_read_data(reader, cache_file->adt); -} - -/** \} */ - /* -------------------------------------------------------------------- */ /** \name Read ID: WorkSpace * \{ */ @@ -6371,9 +6349,6 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID * case ID_PA: direct_link_particlesettings(&reader, (ParticleSettings *)id); break; - case ID_CF: - direct_link_cachefile(&reader, (CacheFile *)id); - break; case ID_WS: direct_link_workspace(&reader, (WorkSpace *)id, main); break; @@ -6407,6 +6382,7 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID * case ID_VO: case ID_SIM: case ID_SO: + case ID_CF: /* Do nothing. Handled by IDTypeInfo callback. */ break; } @@ -7036,9 +7012,6 @@ static void lib_link_all(FileData *fd, Main *bmain) case ID_GR: lib_link_collection(&reader, (Collection *)id); break; - case ID_CF: - lib_link_cachefiles(&reader, (CacheFile *)id); - break; case ID_IP: /* XXX deprecated... still needs to be maintained for version patches still. */ lib_link_ipo(&reader, (Ipo *)id); @@ -7076,6 +7049,7 @@ static void lib_link_all(FileData *fd, Main *bmain) case ID_VO: case ID_SIM: case ID_SO: + case ID_CF: /* Do nothing. Handled by IDTypeInfo callback. */ break; } @@ -8003,10 +7977,6 @@ static void expand_scene(BlendExpander *expander, Scene *sce) } } -static void expand_cachefile(BlendExpander *UNUSED(expander), CacheFile *UNUSED(cache_file)) -{ -} - static void expand_workspace(BlendExpander *expander, WorkSpace *workspace) { LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) { @@ -8072,9 +8042,6 @@ void BLO_expand_main(void *fdhandle, Main *mainvar) case ID_PA: expand_particlesettings(&expander, (ParticleSettings *)id); break; - case ID_CF: - expand_cachefile(&expander, (CacheFile *)id); - break; case ID_WS: expand_workspace(&expander, (WorkSpace *)id); break; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 70d68ef5262..171d111b94d 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2055,23 +2055,6 @@ static void write_screen(BlendWriter *writer, bScreen *screen, const void *id_ad } } -static void write_cachefile(BlendWriter *writer, CacheFile *cache_file, const void *id_address) -{ - if (cache_file->id.us > 0 || BLO_write_is_undo(writer)) { - /* Clean up, important in undo case to reduce false detection of changed datablocks. */ - BLI_listbase_clear(&cache_file->object_paths); - cache_file->handle = NULL; - memset(cache_file->handle_filepath, 0, sizeof(cache_file->handle_filepath)); - cache_file->handle_readers = NULL; - - BLO_write_id_struct(writer, CacheFile, id_address, &cache_file->id); - - if (cache_file->adt) { - BKE_animdata_blend_write(writer, cache_file->adt); - } - } -} - static void write_workspace(BlendWriter *writer, WorkSpace *workspace, const void *id_address) { BLO_write_id_struct(writer, WorkSpace, id_address, &workspace->id); @@ -2366,9 +2349,6 @@ static bool write_file_handle(Main *mainvar, case ID_PA: write_particlesettings(&writer, (ParticleSettings *)id_buffer, id); break; - case ID_CF: - write_cachefile(&writer, (CacheFile *)id_buffer, id); - break; case ID_ME: case ID_LT: case ID_AC: @@ -2399,6 +2379,7 @@ static bool write_file_handle(Main *mainvar, case ID_VO: case ID_SIM: case ID_SO: + case ID_CF: /* Do nothing, handled in IDTypeInfo callback. */ break; case ID_LI: -- cgit v1.2.3