Cleanup: Comments & naming to File Browser file-listing logic more clear
Always found this function a bit hard to follow, hopefully these small tweaks improve that slightly.
This commit is contained in:
@@ -3299,7 +3299,8 @@ static std::optional<int> filelist_readjob_list_lib(FileListReadJob *job_params,
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const bool group_came_from_path = group != nullptr;
|
||||
/* The root path contains an ID group (e.g. "Materials" or "Objects"). */
|
||||
const bool has_group = group != nullptr;
|
||||
|
||||
/* Try read from indexer_runtime. */
|
||||
/* Indexing returns all entries in a blend file. We should ignore the index when listing a group
|
||||
@@ -3309,7 +3310,7 @@ static std::optional<int> filelist_readjob_list_lib(FileListReadJob *job_params,
|
||||
*
|
||||
* Adding support for partial reading/updating indexes would increase the complexity.
|
||||
*/
|
||||
const bool use_indexer = !group_came_from_path;
|
||||
const bool use_indexer = !has_group;
|
||||
FileIndexerEntries indexer_entries = {nullptr};
|
||||
if (use_indexer) {
|
||||
int read_from_index = 0;
|
||||
@@ -3344,7 +3345,8 @@ static std::optional<int> filelist_readjob_list_lib(FileListReadJob *job_params,
|
||||
|
||||
int group_len = 0;
|
||||
int datablock_len = 0;
|
||||
if (group_came_from_path) {
|
||||
/* Read only the datablocks from this group. */
|
||||
if (has_group) {
|
||||
const int idcode = groupname_to_code(group);
|
||||
LinkNode *datablock_infos = BLO_blendhandle_get_datablock_info(
|
||||
libfiledata, idcode, options & LIST_LIB_ASSETS_ONLY, &datablock_len);
|
||||
@@ -3352,6 +3354,7 @@ static std::optional<int> filelist_readjob_list_lib(FileListReadJob *job_params,
|
||||
job_params, entries, datablock_infos, false, idcode, group);
|
||||
BLO_datablock_info_linklist_free(datablock_infos);
|
||||
}
|
||||
/* Read all datablocks from all groups. */
|
||||
else {
|
||||
LinkNode *groups = BLO_blendhandle_get_linkable_groups(libfiledata);
|
||||
group_len = BLI_linklist_count(groups);
|
||||
|
||||
Reference in New Issue
Block a user