diff options
author | Bastien Montagne <mont29> | 2021-11-29 16:20:58 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-11-29 16:22:38 +0300 |
commit | e5e8db73df86ee04260c5f2bd2c61dfa8eb7943f (patch) | |
tree | 46a5840efb51a363f17e64b93d5132679a5dbec4 /source/blender/editors/asset/intern/asset_ops.cc | |
parent | 6ae34bb0714859d9ef0b7fa2aceb16b4531df48f (diff) |
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
Diffstat (limited to 'source/blender/editors/asset/intern/asset_ops.cc')
-rw-r--r-- | source/blender/editors/asset/intern/asset_ops.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/source/blender/editors/asset/intern/asset_ops.cc b/source/blender/editors/asset/intern/asset_ops.cc index 0177a06aa0a..f182dcc1ad0 100644 --- a/source/blender/editors/asset/intern/asset_ops.cc +++ b/source/blender/editors/asset/intern/asset_ops.cc @@ -880,11 +880,12 @@ struct FileCheckCallbackInfo { bool external_file_found; }; -static bool external_file_check_callback(void *callback_info_ptr, +static bool external_file_check_callback(BPathForeachPathData *bpath_data, char * /*path_dst*/, const char *path_src) { - FileCheckCallbackInfo *callback_info = static_cast<FileCheckCallbackInfo *>(callback_info_ptr); + FileCheckCallbackInfo *callback_info = static_cast<FileCheckCallbackInfo *>( + bpath_data->user_data); BKE_reportf(callback_info->reports, RPT_ERROR, "Unable to install asset bundle, has external dependency \"%s\"", @@ -904,12 +905,19 @@ static bool has_external_files(Main *bmain, struct ReportList *reports) { struct FileCheckCallbackInfo callback_info = {reports, false}; - BKE_bpath_traverse_main( - bmain, - &external_file_check_callback, - BKE_BPATH_TRAVERSE_SKIP_PACKED /* Packed files are fine. */ - | BKE_BPATH_TRAVERSE_SKIP_MULTIFILE /* Only report multifiles once, it's enough. */, - &callback_info); + eBPathForeachFlag flag = static_cast<eBPathForeachFlag>( + BKE_BPATH_FOREACH_PATH_SKIP_PACKED /* Packed files are fine. */ + | BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE); /* Only report multifiles once, it's enough. */ + + BPathForeachPathData bpath_data = { + /* bmain */ bmain, + /* callback_function */ &external_file_check_callback, + /* flag */ flag, + /* user_data */ &callback_info, + /* absolute_base_path */ nullptr, + }; + + BKE_bpath_foreach_path_main(&bpath_data); return callback_info.external_file_found; } |