Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2021-01-28 20:04:10 +0300
committerBastien Montagne <bastien@blender.org>2021-02-03 11:53:56 +0300
commit4884153823865bbe4bdd365162c71bb45df4081f (patch)
treeb85bb02939bedbe164901261051b26d383f621b2 /source/blender/blenloader
parent2ce1400297d725a2b5caeec016ef77b4c6c204a7 (diff)
BPY: allow `bpy.data.libraries.load()` to filter out non-asset data-blocks.
Differential Revision: https://developer.blender.org/D10237
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/BLO_readfile.h4
-rw-r--r--source/blender/blenloader/intern/blend_validate.c2
-rw-r--r--source/blender/blenloader/intern/readblenentry.c12
3 files changed, 14 insertions, 4 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 1d7c5d8a1d3..7dbe73cbd6a 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -129,7 +129,9 @@ BlendHandle *BLO_blendhandle_from_memory(const void *mem, int memsize);
struct LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh,
int ofblocktype,
- int *tot_names);
+
+ const bool use_assets_only,
+ int *r_tot_names);
struct LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh,
int ofblocktype,
int *tot_info_items);
diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c
index c281e2fa643..ea3ecc21ecf 100644
--- a/source/blender/blenloader/intern/blend_validate.c
+++ b/source/blender/blenloader/intern/blend_validate.c
@@ -112,7 +112,7 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports)
}
int totnames = 0;
- LinkNode *names = BLO_blendhandle_get_datablock_names(bh, GS(id->name), &totnames);
+ LinkNode *names = BLO_blendhandle_get_datablock_names(bh, GS(id->name), false, &totnames);
for (; id != NULL; id = id->next) {
if (id->lib == NULL) {
is_valid = false;
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 296480fc2e4..f1b15b61d06 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -135,9 +135,14 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
* \param bh: The blendhandle to access.
* \param ofblocktype: The type of names to get.
* \param tot_names: The length of the returned list.
+ * \param use_assets_only: Only list IDs marked as assets.
* \return A BLI_linklist of strings. The string links should be freed with #MEM_freeN().
*/
-LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype, int *tot_names)
+LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh,
+ int ofblocktype,
+
+ const bool use_assets_only,
+ int *r_tot_names)
{
FileData *fd = (FileData *)bh;
LinkNode *names = NULL;
@@ -147,6 +152,9 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype,
for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
if (bhead->code == ofblocktype) {
const char *idname = blo_bhead_id_name(fd, bhead);
+ if (use_assets_only && blo_bhead_id_asset_data_address(fd, bhead) == NULL) {
+ continue;
+ }
BLI_linklist_prepend(&names, BLI_strdup(idname + 2));
tot++;
@@ -156,7 +164,7 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype,
}
}
- *tot_names = tot;
+ *r_tot_names = tot;
return names;
}