From e5e8db73df86ee04260c5f2bd2c61dfa8eb7943f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 29 Nov 2021 14:20:58 +0100 Subject: Refactor BKE_bpath module. The main goal of this refactor is to make BPath module use `IDTypeInfo`, and move each ID-specific part of the `foreach_path` looper into their own IDTypeInfo struct, using a new `foreach_path` callback. Additionally, following improvements/cleanups are included: * Attempt to get better, more consistent namings. ** In particular, move from `path_visitor` to more standard `foreach_path`. * Update and extend documentation. ** API doc was moved to header, according to recent discussions on this topic. * Remove `BKE_bpath_relocate_visitor` from API, this is specific callback that belongs in `lib_id.c` user code. NOTE: This commit is expected to be 100% non-behavioral-change. This implies that several potential further changes were only noted as comments (like using a more generic solution for `lib_id_library_local_paths`, addressing inconsistencies like path of packed libraries always being skipped, regardless of the `BKE_BPATH_FOREACH_PATH_SKIP_PACKED` `eBPathForeachFlag` flag value, etc.). NOTE: basic unittests were added to master already in rBdcc500e5a265093bc9cc. Reviewed By: brecht Differential Revision: https://developer.blender.org/D13381 --- source/blender/blenkernel/intern/cachefile.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/blenkernel/intern/cachefile.c') diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c index 3330b33cdd7..2e0e95b19c5 100644 --- a/source/blender/blenkernel/intern/cachefile.c +++ b/source/blender/blenkernel/intern/cachefile.c @@ -40,6 +40,7 @@ #include "BLT_translation.h" #include "BKE_anim_data.h" +#include "BKE_bpath.h" #include "BKE_cachefile.h" #include "BKE_idtype.h" #include "BKE_lib_id.h" @@ -94,6 +95,12 @@ static void cache_file_free_data(ID *id) BLI_freelistN(&cache_file->object_paths); } +static void cache_file_foreach_path(ID *id, BPathForeachPathData *bpath_data) +{ + CacheFile *cache_file = (CacheFile *)id; + BKE_bpath_foreach_path_fixed_process(bpath_data, cache_file->filepath); +} + static void cache_file_blend_write(BlendWriter *writer, ID *id, const void *id_address) { CacheFile *cache_file = (CacheFile *)id; @@ -142,6 +149,7 @@ IDTypeInfo IDType_ID_CF = { .make_local = NULL, .foreach_id = NULL, .foreach_cache = NULL, + .foreach_path = cache_file_foreach_path, .owner_get = NULL, .blend_write = cache_file_blend_write, -- cgit v1.2.3