From 81a775b6d90bed3e816d84c49a8884e4c1d3c0bc Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 27 Jun 2025 21:47:48 +0200 Subject: [PATCH] Revert "Refactor: BLO: ID listing in blendfile: factorize 'read & check' logic." This reverts commit 7e2b90df40f350a4388e0047ef2bf251f381fbd0. It mysteriously and spectacularly fails on WoA... --- .../blenloader/intern/readblenentry.cc | 44 ++++++------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/source/blender/blenloader/intern/readblenentry.cc b/source/blender/blenloader/intern/readblenentry.cc index 5116c3de4d3..0300bae3cbf 100644 --- a/source/blender/blenloader/intern/readblenentry.cc +++ b/source/blender/blenloader/intern/readblenentry.cc @@ -75,25 +75,6 @@ BlendHandle *BLO_blendhandle_from_memory(const void *mem, return bh; } -/* Return `false` if the block should be skipped because it is either an invalid block, or it does - * not meet to required conditions. */ -static bool blendhandle_load_id_data_and_validate(FileData *fd, - BHead *bhead, - bool use_assets_only, - const char *&r_idname, - AssetMetaData *&r_asset_meta_data) -{ - r_idname = blo_bhead_id_name(fd, bhead); - if (!r_idname || r_idname[0] == '\0') { - return false; - } - r_asset_meta_data = blo_bhead_id_asset_data_address(fd, bhead); - if (use_assets_only && r_asset_meta_data == nullptr) { - return false; - } - return true; -} - LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype, const bool use_assets_only, @@ -106,11 +87,11 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) { if (bhead->code == ofblocktype) { - const char *idname; - AssetMetaData *asset_meta_data; - if (!blendhandle_load_id_data_and_validate( - fd, bhead, use_assets_only, idname, asset_meta_data)) - { + const char *idname = blo_bhead_id_name(fd, bhead); + if (!idname) { + continue; + } + if (use_assets_only && blo_bhead_id_asset_data_address(fd, bhead) == nullptr) { continue; } @@ -145,15 +126,18 @@ LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh, if (bhead->code == ofblocktype) { BHead *id_bhead = bhead; - const char *idname; - AssetMetaData *asset_meta_data; - if (!blendhandle_load_id_data_and_validate( - fd, id_bhead, use_assets_only, idname, asset_meta_data)) - { + const char *idname = blo_bhead_id_name(fd, bhead); + if (!idname) { continue; } - const char *name = idname + 2; + AssetMetaData *asset_meta_data = blo_bhead_id_asset_data_address(fd, bhead); + + const bool is_asset = asset_meta_data != nullptr; + const bool skip_datablock = use_assets_only && !is_asset; + if (skip_datablock) { + continue; + } BLODataBlockInfo *info = MEM_mallocN(__func__); /* Lastly, read asset data from the following blocks. */