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:
Diffstat (limited to 'source/blender/blenloader/intern/readfile.c')
-rw-r--r--source/blender/blenloader/intern/readfile.c50
1 files changed, 35 insertions, 15 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 62188273457..353eb336c42 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -968,15 +968,15 @@ static BHead *blo_bhead_read_full(FileData *fd, BHead *thisblock)
/* Warning! Caller's responsibility to ensure given bhead **is** an ID one! */
const char *blo_bhead_id_name(const FileData *fd, const BHead *bhead)
{
- return (const char *)POINTER_OFFSET(bhead, sizeof(*bhead) + fd->id_name_offs);
+ return (const char *)POINTER_OFFSET(bhead, sizeof(*bhead) + fd->id_name_offset);
}
/* Warning! Caller's responsibility to ensure given bhead **is** an ID one! */
AssetMetaData *blo_bhead_id_asset_data_address(const FileData *fd, const BHead *bhead)
{
BLI_assert(BKE_idtype_idcode_is_valid(bhead->code));
- return (fd->id_asset_data_offs >= 0) ?
- *(AssetMetaData **)POINTER_OFFSET(bhead, sizeof(*bhead) + fd->id_asset_data_offs) :
+ return (fd->id_asset_data_offset >= 0) ?
+ *(AssetMetaData **)POINTER_OFFSET(bhead, sizeof(*bhead) + fd->id_asset_data_offset) :
NULL;
}
@@ -1055,9 +1055,9 @@ static bool read_file_dna(FileData *fd, const char **r_error_message)
fd->reconstruct_info = DNA_reconstruct_info_create(
fd->filesdna, fd->memsdna, fd->compflags);
/* used to retrieve ID names from (bhead+1) */
- fd->id_name_offs = DNA_elem_offset(fd->filesdna, "ID", "char", "name[]");
- BLI_assert(fd->id_name_offs != -1);
- fd->id_asset_data_offs = DNA_elem_offset(
+ fd->id_name_offset = DNA_elem_offset(fd->filesdna, "ID", "char", "name[]");
+ BLI_assert(fd->id_name_offset != -1);
+ fd->id_asset_data_offset = DNA_elem_offset(
fd->filesdna, "ID", "AssetMetaData", "*asset_data");
return true;
@@ -2425,7 +2425,9 @@ static void direct_link_id_common(
id->session_uuid = MAIN_ID_SESSION_UUID_UNSET;
}
- BKE_lib_libblock_session_uuid_ensure(id);
+ if ((tag & LIB_TAG_TEMP_MAIN) == 0) {
+ BKE_lib_libblock_session_uuid_ensure(id);
+ }
id->lib = current_library;
id->us = ID_FAKE_USERS(id);
@@ -3169,7 +3171,9 @@ static ID *create_placeholder(Main *mainvar, const short idcode, const char *idn
BLI_addtail(lb, ph_id);
id_sort_by_name(lb, ph_id, NULL);
- BKE_lib_libblock_session_uuid_ensure(ph_id);
+ if ((tag & LIB_TAG_TEMP_MAIN) == 0) {
+ BKE_lib_libblock_session_uuid_ensure(ph_id);
+ }
return ph_id;
}
@@ -4412,7 +4416,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
if (id == NULL) {
/* ID has not been read yet, add placeholder to the main of the
* library it belongs to, so that it will be read later. */
- read_libblock(fd, libmain, bhead, LIB_TAG_INDIRECT, false, NULL);
+ read_libblock(fd, libmain, bhead, fd->id_tag_extra | LIB_TAG_INDIRECT, false, NULL);
/* commented because this can print way too much */
// if (G.debug & G_DEBUG) printf("expand_doit: other lib %s\n", lib->filepath);
@@ -4467,7 +4471,12 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
ID *id = is_yet_read(fd, mainvar, bhead);
if (id == NULL) {
- read_libblock(fd, mainvar, bhead, LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT, false, NULL);
+ read_libblock(fd,
+ mainvar,
+ bhead,
+ fd->id_tag_extra | LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT,
+ false,
+ NULL);
}
else {
/* Convert any previously read weak link to regular link
@@ -4848,7 +4857,7 @@ static ID *link_named_part(
id = is_yet_read(fd, mainl, bhead);
if (id == NULL) {
/* not read yet */
- const int tag = force_indirect ? LIB_TAG_INDIRECT : LIB_TAG_EXTERN;
+ const int tag = ((force_indirect ? LIB_TAG_INDIRECT : LIB_TAG_EXTERN) | fd->id_tag_extra);
read_libblock(fd, mainl, bhead, tag | LIB_TAG_NEED_EXPAND, false, &id);
if (id) {
@@ -4989,10 +4998,18 @@ static void library_link_clear_tag(Main *mainvar, const int flag)
}
}
-static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepath, const int flag)
+static Main *library_link_begin(
+ Main *mainvar, FileData **fd, const char *filepath, const int flag, const int id_tag_extra)
{
Main *mainl;
+ /* Only allow specific tags to be set as extra,
+ * otherwise this could conflict with library loading logic.
+ * Other flags can be added here, as long as they are safe. */
+ BLI_assert((id_tag_extra & ~LIB_TAG_TEMP_MAIN) == 0);
+
+ (*fd)->id_tag_extra = id_tag_extra;
+
(*fd)->mainlist = MEM_callocN(sizeof(ListBase), "FileData.mainlist");
if (flag & BLO_LIBLINK_NEEDS_ID_TAG_DOIT) {
@@ -5018,22 +5035,25 @@ static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepa
void BLO_library_link_params_init(struct LibraryLink_Params *params,
struct Main *bmain,
- const int flag)
+ const int flag,
+ const int id_tag_extra)
{
memset(params, 0, sizeof(*params));
params->bmain = bmain;
params->flag = flag;
+ params->id_tag_extra = id_tag_extra;
}
void BLO_library_link_params_init_with_context(struct LibraryLink_Params *params,
struct Main *bmain,
const int flag,
+ const int id_tag_extra,
/* Context arguments. */
struct Scene *scene,
struct ViewLayer *view_layer,
const struct View3D *v3d)
{
- BLO_library_link_params_init(params, bmain, flag);
+ BLO_library_link_params_init(params, bmain, flag, id_tag_extra);
if (scene != NULL) {
/* Tagging is needed for instancing. */
params->flag |= BLO_LIBLINK_NEEDS_ID_TAG_DOIT;
@@ -5058,7 +5078,7 @@ Main *BLO_library_link_begin(BlendHandle **bh,
const struct LibraryLink_Params *params)
{
FileData *fd = (FileData *)(*bh);
- return library_link_begin(params->bmain, &fd, filepath, params->flag);
+ return library_link_begin(params->bmain, &fd, filepath, params->flag, params->id_tag_extra);
}
static void split_main_newid(Main *mainptr, Main *main_newid)