29#include "fmt/format.h"
32#define DNA_DEPRECATED_ALLOW
113#define U (*((const UserDef *)&U))
172#define USE_BHEAD_READ_ON_DEMAND
175#define USE_GHASH_BHEAD
178#define USE_GHASH_RESTORE_POINTER
191#ifdef USE_BHEAD_READ_ON_DEMAND
201#define BHEADN_FROM_BHEAD(bh) ((BHeadN *)POINTER_OFFSET(bh, -int(offsetof(BHeadN, bhead))))
207#define BHEAD_USE_READ_ON_DEMAND(bhead) ((bhead)->code == BLO_CODE_DATA)
215 char fixed_buf[1024];
220 vsnprintf(fixed_buf,
sizeof(fixed_buf),
format, args);
223 fixed_buf[
sizeof(fixed_buf) - 1] =
'\0';
227 if (
G.background == 0) {
235 return lib->runtime.parent ?
lib->runtime.parent->runtime.filepath_abs :
"<direct>";
257 return MEM_new<OldNewMap>(__func__);
266 if (oldaddr ==
nullptr || newaddr ==
nullptr) {
286 if (entry ==
nullptr) {
289 if (increase_users) {
298 if (addr ==
nullptr) {
316 if (new_addr.nr == 0) {
339 if (from->is_read_invalid) {
352 Main *tojoin, *mainl;
354 mainl =
static_cast<Main *
>(mainlist->
first);
356 if (mainl->
id_map !=
nullptr) {
365 while ((tojoin = mainl->
next)) {
370 tojoin->
next = tojoin->
prev =
nullptr;
377 for (
ID *
id =
static_cast<ID *
>(lb_src->
first), *idnext; id;
id = idnext) {
378 idnext =
static_cast<ID *
>(
id->next);
381 if ((
uint(id->lib->runtime.temp_index) < lib_main_array_len) &&
383 (lib_main_array[id->lib->runtime.temp_index]->
curlib == id->lib))
385 Main *mainvar = lib_main_array[
id->lib->runtime.temp_index];
400 main->next =
nullptr;
406 if (
main->id_map !=
nullptr) {
409 main->id_map =
nullptr;
417 Main **lib_main_array =
static_cast<Main **
>(
432 lib->runtime.temp_index = i;
433 lib_main_array[i] = libmain;
439 ID *
id =
static_cast<ID *
>(lbarray[i]->
first);
440 if (
id ==
nullptr ||
GS(id->name) ==
ID_LI) {
444 split_libdata(lbarray[i], lib_main_array, lib_main_array_len);
471 main->curlib->runtime.versionfile =
main->versionfile;
472 main->curlib->runtime.subversionfile =
main->subversionfile;
482 return bhead->
code <= 0xFFFF;
491 const short id_type_code = bhead->
code & 0xFFFF;
495#ifdef USE_GHASH_BHEAD
501 bool is_link =
false;
506 if (code_prev != bhead->
code) {
507 code_prev = bhead->
code;
523 if (code_prev != bhead->
code) {
524 code_prev = bhead->
code;
544 STRNCPY(filepath_abs, filepath);
578 STRNCPY(
lib->runtime.filepath_abs, filepath_abs);
595 for (; bmain->
prev !=
nullptr; bmain = bmain->
prev) {
602 "A critical error happened (the blend file is likely corrupted): %s",
630 if ((bhead->
code & 0xFFFF) == 0) {
644 if ((bhead->
code & 0xFFFF) == 0) {
661 bhead4->
len = bhead8->
len;
667 if (do_endian_swap) {
673 memcpy(&old, &bhead8->
old, 8);
674 bhead4->
old =
int(old >> 3);
677 bhead4->
nr = bhead8->
nr;
686 bhead8->
len = bhead4->
len;
689 bhead8->
old = bhead4->
old;
691 bhead8->
nr = bhead4->
nr;
697 BHeadN *new_bhead =
nullptr;
717 readsize = fd->
file->
read(fd->
file, &bhead4,
sizeof(bhead4));
730 memcpy(&bhead, &bhead4, std::min(
sizeof(bhead),
sizeof(bhead4)));
740 readsize = fd->
file->
read(fd->
file, &bhead8,
sizeof(bhead8));
753 memcpy(&bhead, &bhead8, std::min(
sizeof(bhead),
sizeof(bhead8)));
773#ifdef USE_BHEAD_READ_ON_DEMAND
778 new_bhead->
next = new_bhead->
prev =
nullptr;
782 new_bhead->
bhead = bhead;
783 const off64_t seek_new = fd->
file->
seek(fd->
file, bhead.
len, SEEK_CUR);
799 new_bhead =
static_cast<BHeadN *
>(
802 new_bhead->
next = new_bhead->
prev =
nullptr;
803#ifdef USE_BHEAD_READ_ON_DEMAND
808 new_bhead->
bhead = bhead;
812 if (readsize != bhead.
len) {
842 BHead *bhead =
nullptr;
848 if (new_bhead ==
nullptr) {
853 bhead = &new_bhead->
bhead;
864 return (prev) ? &prev->bhead :
nullptr;
869 BHeadN *new_bhead =
nullptr;
870 BHead *bhead =
nullptr;
878 new_bhead = new_bhead->
next;
879 if (new_bhead ==
nullptr) {
887 bhead = &new_bhead->
bhead;
893#ifdef USE_BHEAD_READ_ON_DEMAND
911 if (fd->
file->
seek(fd->
file, offset_backup, SEEK_SET) == -1) {
930 return &new_bhead_data->
bhead;
953 readsize = fd->
file->
read(fd->
file, header,
sizeof(header));
955 if (readsize ==
sizeof(header) &&
STREQLEN(header,
"BLENDER", 7) &&
ELEM(header[7],
'_',
'-') &&
956 ELEM(header[8],
'v',
'V') &&
957 (isdigit(header[9]) && isdigit(header[10]) && isdigit(header[11])))
962 if (header[7] ==
'_') {
964 if (
sizeof(
void *) != 4) {
969 if (
sizeof(
void *) != 8) {
982 memcpy(num, header + 9, 3);
986 else if (
STREQLEN(header,
"BLENDER", 7)) {
1016 subversion = atoi(num);
1020 const bool do_alias =
false;
1022 &bhead[1], bhead->
len, do_endian_swap,
true, do_alias, r_error_message);
1033 fd->
filesdna,
"ID",
"char",
"name[]");
1036 fd->
filesdna,
"ID",
"AssetMetaData",
"*asset_data");
1048 *r_error_message =
"Missing DNA block";
1055 int *blend_thumb =
nullptr;
1060 int *data = (
int *)(bhead + 1);
1062 if (bhead->
len <
sizeof(
int[2])) {
1066 if (do_endian_swap) {
1071 const int width = data[0];
1072 const int height = data[1];
1133 char writer_ver_str[16];
1134 char min_reader_ver_str[16];
1143 writer_ver_str,
sizeof(writer_ver_str),
short(fd->
fileversion), -1);
1145 min_reader_ver_str,
sizeof(min_reader_ver_str), fg->
minversion, -1);
1149 "The file was saved by a newer version, open it with Blender %s or later",
1150 min_reader_ver_str);
1152 "%s: File saved by a newer version of Blender (%s), Blender %s or later is "
1153 "needed to open it.",
1156 min_reader_ver_str);
1171 const char *error_message =
nullptr;
1174 reports,
RPT_ERROR,
"Failed to read blend file '%s': %s", fd->
relabase, error_message);
1187 "Cannot read blend file '%s', incomplete header, may be from a newer version of Blender",
1211 if (rawfile ==
nullptr || rawfile->
read(rawfile, header,
sizeof(header)) !=
sizeof(header)) {
1214 "Unable to read '%s': %s",
1216 errno ? strerror(errno) :
RPT_(
"insufficient content"));
1218 rawfile->
close(rawfile);
1227 rawfile->
seek(rawfile, 0, SEEK_SET);
1230 if (memcmp(header,
"BLENDER",
sizeof(header)) == 0) {
1233 if (file ==
nullptr) {
1241 if (file !=
nullptr) {
1247 if (file !=
nullptr) {
1253 if (rawfile !=
nullptr) {
1254 rawfile->
close(rawfile);
1256 if (file ==
nullptr) {
1274 "Unable to open '%s': %s",
1276 errno ? strerror(errno) :
RPT_(
"unknown error reading file"));
1285 if (fd !=
nullptr) {
1302 if (fd !=
nullptr) {
1330 if (file ==
nullptr) {
1332 mem_file->
close(mem_file);
1367# ifdef USE_BHEAD_READ_ON_DEMAND
1407#ifdef USE_GHASH_BHEAD
1429 const int width = fd_data[0];
1430 const int height = fd_data[1];
1437 data->width = width;
1438 data->height = height;
1439 memcpy(data->rect, &fd_data[2], data_size -
sizeof(*data));
1491 const bool is_linked_only,
1494 return newlibadr(fd, self_id, is_linked_only, adr);
1506 entry.nr =
GS(((
ID *)newp)->name);
1520 if (mainptr->curlib) {
1521 fd = mainptr->curlib->runtime.filedata;
1553 ID *
id,
const IDCacheKey *key,
void **cache_p,
uint ,
void *cache_storage_v)
1563 *storage_key = *key;
1566 storage_value->
cache_v = *cache_p;
1573 ID *
id,
const IDCacheKey *key,
void **cache_p,
uint flags,
void *cache_storage_v)
1577 if (cache_storage ==
nullptr) {
1598 if (storage_value ==
nullptr) {
1603 *cache_p = storage_value->
cache_v;
1608 ID * ,
const IDCacheKey *key,
void **cache_p,
uint ,
void *cache_storage_v)
1614 if (storage_value ==
nullptr) {
1641 if (
id ==
nullptr) {
1671 if (
id ==
nullptr) {
1710 int blocksize, nblocks;
1713 data = (
char *)(bhead + 1);
1717 nblocks = bhead->
nr;
1733 const char *blockname,
1740 using keyT =
const std::pair<const std::string, const int>;
1745 constexpr std::string_view STORAGE_ID =
"readfile";
1751 std::string(STORAGE_ID));
1757 const bool is_id_data = !blockname && (id_type_index >= 0 && id_type_index <
INDEX_ID_MAX);
1761 static const std::array<std::string, INDEX_ID_MAX> id_alloc_names = [] {
1762 auto n =
decltype(id_alloc_names)();
1763 for (
int idtype_index = 0; idtype_index <
INDEX_ID_MAX; idtype_index++) {
1769 n[size_t(idtype_index)] =
"UNKNWOWN";
1772 n[size_t(idtype_index)] = idtype_info->
name;
1778 const std::string block_alloc_name = is_id_data ? id_alloc_names[id_type_index] : blockname;
1780 keyT key{block_alloc_name + struct_name, bh->
nr};
1782 const std::string alloc_string = fmt::format(
1783 (is_id_data ?
"{}{} (for ID type '{}')" :
"{}{} (for block '{}')"),
1785 bh->
nr > 1 ? fmt::format(
"[{}]", bh->
nr) :
"",
1787 return storage.
insert(key, alloc_string);
1789 return storage.
find(key);
1796 return storage.
insert(id_type_index,
"Data from UNKNOWN");
1799 const std::string alloc_string = fmt::format(
"Data from '{}' ID type", id_type->
name);
1800 return storage.
insert(id_type_index, alloc_string);
1802 return storage.
find(id_type_index);
1810 void *temp =
nullptr;
1813#ifdef USE_BHEAD_READ_ON_DEMAND
1814 BHead *bh_orig = bh;
1823#ifdef USE_BHEAD_READ_ON_DEMAND
1827 fd->
flags &= ~FD_FLAGS_FILE_OK;
1836 const char *alloc_name =
get_alloc_name(fd, bh, blockname, id_type_index);
1838#ifdef USE_BHEAD_READ_ON_DEMAND
1842 fd->
flags &= ~FD_FLAGS_FILE_OK;
1854#ifdef USE_BHEAD_READ_ON_DEMAND
1856 memcpy(temp, (bh + 1), bh->
len);
1862 fd->
flags &= ~FD_FLAGS_FILE_OK;
1868 memcpy(temp, (bh + 1), bh->
len);
1873#ifdef USE_BHEAD_READ_ON_DEMAND
1874 if (bh_orig != bh) {
1889 return (bhead->
len) ? (
const void *)(bhead + 1) :
nullptr;
1913 ln->
next =
static_cast<Link *
>(poin);
1934 if (nodetree !=
nullptr) {
1937 if (nodetree->
owner_id ==
nullptr) {
1939 "NULL owner_id pointer for embedded NodeTree of %s, should never happen",
1943 else if (nodetree->
owner_id !=
id) {
1945 "Inconsistent owner_id pointer for embedded NodeTree of %s, should never happen",
1953 if (scene->master_collection !=
nullptr) {
1956 if (scene->master_collection->owner_id ==
nullptr) {
1958 "NULL owner_id pointer for embedded Scene Collection of %s, should never happen",
1960 scene->master_collection->owner_id = id;
1962 else if (scene->master_collection->owner_id !=
id) {
1964 "Inconsistent owner_id pointer for embedded Scene Collection of %s, should "
1967 scene->master_collection->owner_id = id;
2013 if (nodetree !=
nullptr && *nodetree !=
nullptr) {
2026 if (scene->master_collection !=
nullptr) {
2030 &scene->master_collection->
id,
2031 id_old !=
nullptr ? &((
Scene *)id_old)->master_collection->id :
2051 const ID *id_target,
2052 const ID *id_current,
2053 const bool is_identical)
2058 int recalc = id_target->
recalc;
2060 if (id_current ==
nullptr) {
2069 if (!is_identical) {
2078 recalc |= id_current->
recalc;
2105 id->lib = current_library;
2108 id->flag &= ~ID_FLAG_FAKEUSER;
2112 id->newid =
nullptr;
2113 id->orig_id =
nullptr;
2114 id->py_instance =
nullptr;
2129 id->library_weak_reference =
nullptr;
2143 if (id->asset_data) {
2152 if (id->properties) {
2158 id->flag &= ~ID_FLAG_INDIRECT_WEAK_LINK;
2170 id->recalc_after_undo_push = 0;
2174 id->recalc_after_undo_push = 0;
2178 if (id->override_library) {
2181 if (id->override_library !=
nullptr) {
2186 id->override_library->runtime =
nullptr;
2215 block->uid = key->
uidgen++;
2225#ifdef USE_SETSCENE_CHECK
2229static bool scene_validate_setscene__liblink(
Scene *sce,
const int totscene)
2234 if (sce->
set ==
nullptr) {
2238 for (a = 0, sce_iter = sce; sce_iter->
set; sce_iter = sce_iter->
set, a++) {
2263#ifdef USE_SETSCENE_CHECK
2267 sce->
flag &= ~SCE_READFILE_LIBLINK_NEED_SETSCENE_CHECK;
2268 if (!scene_validate_setscene__liblink(sce, totscene)) {
2278#undef USE_SETSCENE_CHECK
2301 if (newmain->curlib) {
2302 if (
BLI_path_cmp(newmain->curlib->runtime.filepath_abs,
lib->runtime.filepath_abs) == 0) {
2305 RPT_(
"Library '%s', '%s' had multiple instances, save and reload!"),
2307 lib->runtime.filepath_abs);
2340 lib->runtime.parent =
nullptr;
2350 if (basepath ==
nullptr || basepath[0] ==
'\0') {
2385 const bool was_liboverride)
2390 *((
short *)ph_id->
name) = idcode;
2398 if (was_liboverride) {
2409 if (mainvar->
id_map !=
nullptr) {
2425 ID *obdata =
static_cast<ID *
>(ob->data);
2455 bool success =
true;
2457 switch (
GS(id->name)) {
2481 const char *allocname,
2482 const int id_type_index)
2487 void *data =
read_struct(fd, bhead, allocname, id_type_index);
2492 "Blendfile corruption: Invalid, or multiple `bhead` with same old address "
2493 "value (%p) for a given ID.",
2548 ID *
id =
static_cast<ID *
>(lbarray[i]->
first);
2579 if (bhead !=
nullptr) {
2604 if (id_old ==
nullptr) {
2611 for (libmain = libmain->
next; libmain; libmain = libmain->
next) {
2612 if (&libmain->
curlib->
id == id_old) {
2616 " compare with %s -> match (existing libpath: %s)",
2644 if (*r_id_old ==
nullptr) {
2649 if (*r_id_old ==
nullptr) {
2652 " from %s (%s): NOT found",
2660 " from %s (%s): found by name",
2671 " from %s (%s): found by session_uid",
2706 id_old->
newid =
nullptr;
2709 const short idcode =
GS(id_old->
name);
2731 ob->
mode &= ~OB_MODE_EDIT;
2746 const short idcode =
GS(id->name);
2814 &
LOG_UNDO, 2,
"UNDO: skip restore datablock %s, 'NO_MEMFILE_UNDO' type of ID", id->name);
2831 if (!do_partial_undo) {
2834 "UNDO: read %s (uid %u) -> no partial undo, always read at new address",
2845 "UNDO: read %s (uid %u) -> keep identical datablock",
2854 if (id_old !=
nullptr) {
2858 "UNDO: read %s (uid %u) -> read to old existing address",
2867 &
LOG_UNDO, 2,
"UNDO: read %s (uid %u) -> read at new address", id->name, id->session_uid);
2882 const bool placeholder_set_indirect_extern,
2890 ID *id_old =
nullptr;
2896 if (
main->id_map !=
nullptr && id_old !=
nullptr) {
2907 const char *blockname =
nullptr;
2911 const char *blockname =
get_alloc_name(fd, bhead,
nullptr, id_type_index);
2913 ID *
id =
static_cast<ID *
>(
read_struct(fd, bhead, blockname, id_type_index));
2914 if (
id ==
nullptr) {
2922 const short idcode =
GS(id->name);
2924 if (lb ==
nullptr) {
2926 CLOG_WARN(&
LOG,
"Unknown id code '%c%c'", (idcode & 0xff), (idcode >> 8));
2941 ID *id_target = (do_partial_undo && id_old !=
nullptr) ? id_old : id;
2956 if (placeholder_set_indirect_extern) {
2967 if (
main->id_map !=
nullptr) {
2986 if (r_id !=
nullptr) {
2991 if (do_partial_undo && id_old !=
nullptr) {
2998 if (
main->id_map !=
nullptr) {
3112 if (user ==
nullptr) {
3124 main->is_locked_for_linking =
true;
3127 char build_commit_datetime[32];
3128 time_t temp_time =
main->build_commit_timestamp;
3129 tm *tm = (temp_time) ? gmtime(&temp_time) :
nullptr;
3131 strftime(build_commit_datetime,
sizeof(build_commit_datetime),
"%Y-%m-%d %H:%M", tm);
3134 STRNCPY(build_commit_datetime,
"unknown");
3140 " Version %d sub %d date %s hash %s",
3142 main->subversionfile,
3143 build_commit_datetime,
3147 if (!
main->is_read_invalid) {
3150 if (!
main->is_read_invalid) {
3153 if (!
main->is_read_invalid) {
3156 if (!
main->is_read_invalid) {
3159 if (!
main->is_read_invalid) {
3162 if (!
main->is_read_invalid) {
3165 if (!
main->is_read_invalid) {
3168 if (!
main->is_read_invalid) {
3177 main->is_locked_for_linking =
false;
3186 "Processing %s (%s), %d.%d",
3187 main->curlib ?
main->curlib->filepath :
main->filepath,
3188 main->curlib ?
"LIB" :
"MAIN",
3190 main->subversionfile);
3193 main->is_locked_for_linking =
true;
3195 if (!
main->is_read_invalid) {
3198 if (!
main->is_read_invalid) {
3201 if (!
main->is_read_invalid) {
3204 if (!
main->is_read_invalid) {
3207 if (!
main->is_read_invalid) {
3210 if (!
main->is_read_invalid) {
3213 if (!
main->is_read_invalid) {
3217 main->is_locked_for_linking =
false;
3291 id->tag &= ~ID_TAG_NEED_LINK;
3305 id->orig_id =
nullptr;
3331 reports ? reports->
reports :
nullptr,
3333 "Critical blend-file corruption: Conflicts and/or otherwise invalid data-blocks names "
3334 "(see console for details)");
3363 kmi->
flag &= ~KMI_UPDATE;
3394 keymap->modal_items =
nullptr;
3395 keymap->poll =
nullptr;
3396 keymap->flag &= ~KEYMAP_UPDATE;
3405 if (kmdi->remove_item) {
3408 if (kmdi->add_item) {
3479 if (*id_pointer !=
nullptr) {
3535 ListBase mainlist = {
nullptr,
nullptr};
3570 const int width = data[0];
3571 const int height = data[1];
3596 switch (bhead->
code) {
3628 bhead =
read_libblock(fd, libmain, bhead, 0,
true,
nullptr);
3675 Main *libmain, *libmain_next;
3676 for (libmain = old_main->
next; libmain !=
nullptr; libmain = libmain_next) {
3677 libmain_next = libmain->
next;
3734 if (mainvar->versionfile == 0) {
3738 mainvar->curlib->runtime.filedata :
3754 if (
lib->runtime.filedata) {
3757 lib->runtime.filedata =
nullptr;
3769 else if (
lib->runtime.versionfile == 0) {
3804 std::string cur_view_layer_name = bfd->
cur_view_layer !=
nullptr ?
3866 if (x1->
old > x2->old) {
3869 if (x1->
old < x2->old) {
3942 if (bhead->
old == old) {
3953#ifdef USE_GHASH_BHEAD
3957 *((
short *)idname_full) = idcode;
3958 BLI_strncpy(idname_full + 2, name,
sizeof(idname_full) - 2);
3966 if (bhead->
code == idcode) {
3968 if (
STREQ(idname_test + 2, name)) {
3972 else if (bhead->
code == ENDB) {
3983#ifdef USE_GHASH_BHEAD
3992 if (mainvar->
id_map ==
nullptr) {
4025 if (bhead ==
nullptr) {
4039 if (bheadlib ==
nullptr) {
4047 if (libmain->
curlib ==
nullptr) {
4052 RPT_(
"LIB: Data refers to main .blend file: '%s' from %s"),
4060 if (
id ==
nullptr) {
4077 id->flag &= ~ID_FLAG_INDIRECT_WEAK_LINK;
4096 printf(
"expand_doit: already linked: %s lib: %s\n", id->name,
lib->filepath);
4106 if (
id ==
nullptr) {
4116 id->flag &= ~ID_FLAG_INDIRECT_WEAK_LINK;
4164 for (
bool do_it =
true; do_it;) {
4185 id_iter->
tag &= ~ID_TAG_NEED_EXPAND;
4200 Main *mainl,
FileData *fd,
const short idcode,
const char *name,
const int flag)
4212 if (
id ==
nullptr) {
4225 CLOG_WARN(&
LOG,
"Append: ID '%s' is already linked", id->name);
4228 id->tag &= ~ID_TAG_INDIRECT;
4229 id->flag &= ~ID_FLAG_INDIRECT_WEAK_LINK;
4234 else if (use_placeholders) {
4256 ID *ret_id =
nullptr;
4271 const char *filepath,
4272 const int id_tag_extra)
4297#ifdef USE_GHASH_BHEAD
4307 const int id_tag_extra)
4312 params->id_tag_extra = id_tag_extra;
4318 const int id_tag_extra,
4325 if (scene !=
nullptr) {
4327 params->context.view_layer = view_layer;
4328 params->context.v3d = v3d;
4333 const char *filepath,
4369 if (mainl->
id_map ==
nullptr) {
4391 mainvar =
static_cast<Main *
>((*fd)->mainlist->first);
4417 for (mainvar = ((
Main *)(*fd)->mainlist->first)->
next; mainvar; mainvar = mainvar->
next) {
4436 mainvar =
static_cast<Main *
>((*fd)->mainlist->first);
4494 if (
lib->runtime.filedata ==
reinterpret_cast<FileData *
>(*bh)) {
4496 lib->runtime.filedata =
nullptr;
4498 else if (
lib->runtime.filedata) {
4506 lib->runtime.filedata =
nullptr;
4510 *bh =
reinterpret_cast<BlendHandle *
>(fd);
4543 BHead *bhead =
nullptr;
4554 RPT_(
"LIB: %s: '%s' is directly linked from '%s' (parent '%s'), but is a "
4555 "non-linkable data type"),
4562 id->tag &= ~ID_TAG_ID_LINK_PLACEHOLDER;
4563 id->flag &= ~ID_FLAG_INDIRECT_WEAK_LINK;
4573 "LIB: %s: '%s' missing from '%s', parent '%s'",
4586 id->override_library !=
nullptr) :
4603 ID *
id =
static_cast<ID *
>(lbarray[a]->
first);
4606 ID *id_next =
static_cast<ID *
>(
id->next);
4609 if (mainvar->
id_map !=
nullptr) {
4649 ID *
id =
static_cast<ID *
>(lbarray[a]->
first);
4652 ID *id_next =
static_cast<ID *
>(
id->next);
4654 CLOG_INFO(&
LOG, 3,
"Dropping weak link to '%s'", id->name);
4670 if (fd !=
nullptr) {
4681 RPT_(
"Read packed library: '%s', parent '%s'"),
4693 RPT_(
"Read library: '%s', '%s', parent '%s'"),
4720#ifdef USE_GHASH_BHEAD
4732 if (fd ==
nullptr) {
4735 RPT_(
"Cannot find lib '%s'"),
4760 for (
Main *mainptr = mainl->
next; mainptr; mainptr = mainptr->next) {
4765 "Reading linked data-blocks from %s (%s)",
4766 mainptr->curlib->id.name,
4767 mainptr->curlib->filepath);
4775 if (mainptr->id_map ==
nullptr) {
4791 for (
Main *mainptr = mainl->
next; mainptr; mainptr = mainptr->next) {
4799 for (
Main *mainptr = mainl->
next; mainptr; mainptr = mainptr->next) {
4803 if (mainptr->versionfile) {
4814 if (mainptr->curlib->runtime.filedata) {
4815 do_versions(mainptr->curlib->runtime.filedata, mainptr->curlib, main_newid);
4822 if (mainptr->curlib->runtime.filedata) {
4823 lib_link_all(mainptr->curlib->runtime.filedata, mainptr);
4839 const size_t expected_size)
4841 if (new_address !=
nullptr) {
4845 "Corrupt .blend file, unexpected data size.");
4858 const void *old_address,
4859 const size_t expected_size)
4866 const void *old_address,
4867 const size_t expected_size)
4869 void *new_address =
newdataadr(reader->
fd, old_address);
4874 const char *struct_name,
4876 const void *old_address)
4887 const bool is_linked_only,
4890 return static_cast<ID *
>(
newlibadr(reader->
fd, self_id, is_linked_only,
id));
4909 const size_t expected_elem_size,
4917 Link *ln =
static_cast<Link *
>(list->first);
4918 Link *prev =
nullptr;
4931 *ptr_p =
reinterpret_cast<char *
>(
4937 *ptr_p =
reinterpret_cast<uint8_t *
>(
4943 *ptr_p =
reinterpret_cast<int8_t *
>(
4949 *ptr_p =
reinterpret_cast<int32_t *
>(
4959 *ptr_p =
reinterpret_cast<uint32_t *
>(
4969 *ptr_p =
reinterpret_cast<float *
>(
4984 *ptr_p =
reinterpret_cast<double *
>(
4997 const char *
str = *ptr_p;
5001 if (
str[
len - 1] ==
'\0') {
5006 BLI_assert_msg(0,
"Corrupt .blend file, expected string to be null terminated.");
5028 for (
int i = 0; i < array_size; i++) {
5035 for (
int i = 0; i < array_size; i++) {
5047 for (
int i = 0; i < array_size; i++) {
5057 if (orig_array ==
nullptr) {
5065 void *final_array =
nullptr;
5067 if (file_pointer_size == current_pointer_size) {
5069 final_array = orig_array;
5071 else if (file_pointer_size == 8 && current_pointer_size == 4) {
5078 else if (file_pointer_size == 4 && current_pointer_size == 8) {
5089 *ptr_p = final_array;
5097 const void *old_address = *ptr_p;
5108 sharing_info->add_user();
5109 return {sharing_info, old_address};
5120 if (shared_data->sharing_info) {
5121 shared_data->sharing_info->add_user();
5123 return *shared_data;
5129 const void *new_address = *ptr_p;
5162 return reader->
main;
void BKE_animdata_blend_read_data(BlendDataReader *reader, ID *id)
void BKE_asset_metadata_read(BlendDataReader *reader, AssetMetaData *asset_data)
void BKE_asset_catalog_path_list_blend_read_data(BlendDataReader *reader, ListBase &catalog_path_list)
#define BLENDER_FILE_SUBVERSION
void BKE_blender_version_blendfile_string_from_values(char *str_buff, const size_t str_buff_maxncpy, const short file_version, const short file_subversion)
#define BLENDER_FILE_VERSION
void BKE_collections_after_lib_link(Main *bmain)
void BKE_collection_blend_read_data(BlendDataReader *reader, Collection *collection, ID *owner_id)
void BKE_main_collections_parent_relations_rebuild(Main *bmain)
#define IDP_BlendDataRead(reader, prop)
@ IDTYPE_FLAGS_NO_MEMFILE_UNDO
const IDTypeInfo * BKE_idtype_get_info_from_idtype_index(const int idtype_index)
const IDTypeInfo * BKE_idtype_get_info_from_id(const ID *id)
bool BKE_idtype_cache_key_cmp(const void *key_a_v, const void *key_b_v)
const char * BKE_idtype_idcode_to_name(short idcode)
bool BKE_idtype_idcode_is_linkable(short idcode)
void BKE_idtype_id_foreach_cache(ID *id, IDTypeForeachCacheFunctionCallback function_callback, void *user_data)
int BKE_idtype_idcode_to_index(short idcode)
uint BKE_idtype_cache_key_hash(const void *key_v)
bool BKE_idtype_idcode_is_valid(short idcode)
@ IDTYPE_CACHE_CB_FLAGS_PERSISTENT
void BKE_layer_collection_resync_forbid()
void BKE_layer_collection_resync_allow()
ViewLayer * BKE_view_layer_find(const Scene *scene, const char *layer_name)
void BKE_id_delete(Main *bmain, void *idv) ATTR_NONNULL()
void * BKE_libblock_alloc(Main *bmain, short type, const char *name, int flag) ATTR_WARN_UNUSED_RESULT
void BKE_id_free(Main *bmain, void *idv)
void id_sort_by_name(ListBase *lb, ID *id, ID *id_sorting_hint)
#define MAIN_ID_SESSION_UID_UNSET
void BKE_libblock_init_empty(ID *id) ATTR_NONNULL(1)
void BKE_lib_libblock_session_uid_ensure(ID *id)
void id_us_ensure_real(ID *id)
void BKE_lib_id_swap_full(Main *bmain, ID *id_a, ID *id_b, const bool do_self_remap, const int self_remap_flags)
void * BKE_libblock_alloc_notest(short type) ATTR_WARN_UNUSED_RESULT
void BKE_main_id_refcount_recompute(Main *bmain, bool do_linked_only)
void BKE_main_id_tag_all(Main *mainvar, int tag, bool value)
void BKE_lib_override_library_main_validate(Main *bmain, ReportList *reports)
void BKE_lib_override_library_main_update(Main *bmain)
@ IDWALK_CB_EMBEDDED_NOT_OWNING
@ IDWALK_CB_READFILE_IGNORE
void BKE_library_foreach_ID_link(Main *bmain, ID *id, blender::FunctionRef< LibraryIDLinkCallback > callback, void *user_data, int flag)
@ IDWALK_DO_DEPRECATED_POINTERS
@ IDWALK_NO_ORIG_POINTERS_ACCESS
@ ID_REMAP_SKIP_USER_CLEAR
@ ID_REMAP_SKIP_USER_REFCOUNT
@ ID_REMAP_SKIP_NEVER_NULL_USAGE
@ ID_REMAP_SKIP_UPDATE_TAGGING
@ ID_REMAP_NO_ORIG_POINTERS_ACCESS
#define FOREACH_MAIN_ID_END
ListBase * which_libbase(Main *bmain, short type)
#define FOREACH_MAIN_LISTBASE_ID_END
#define FOREACH_MAIN_LISTBASE_ID_BEGIN(_lb, _id)
#define FOREACH_MAIN_LISTBASE_END
int set_listbasepointers(Main *bmain, ListBase *lb[])
Main * BKE_main_new(void)
#define FOREACH_MAIN_LISTBASE_BEGIN(_bmain, _lb)
void BKE_main_free(Main *bmain)
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
#define MAIN_VERSION_FILE_OLDER_OR_EQUAL(main, ver, subver)
#define BLEN_THUMB_MEMSIZE(_x, _y)
const char * BKE_main_blendfile_path(const Main *bmain) ATTR_NONNULL()
#define BLEN_THUMB_MEMSIZE_IS_VALID(_x, _y)
bool BKE_main_is_empty(Main *bmain)
const char * BKE_main_blendfile_path_from_global()
ID ID ID * BKE_main_idmap_lookup_uid(IDNameLib_Map *id_map, uint session_uid) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Main * BKE_main_idmap_main_get(IDNameLib_Map *id_map) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
IDNameLib_Map * BKE_main_idmap_create(Main *bmain, bool create_valid_ids_set, Main *old_bmain, int idmap_types) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BKE_main_idmap_remove_id(IDNameLib_Map *id_map, const ID *id) ATTR_NONNULL()
void BKE_main_idmap_destroy(IDNameLib_Map *id_map) ATTR_NONNULL()
void BKE_main_idmap_insert_id(IDNameLib_Map *id_map, ID *id) ATTR_NONNULL()
ID * BKE_main_idmap_lookup_name(IDNameLib_Map *id_map, short id_type, const char *name, const Library *lib) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
bool BKE_main_namemap_validate_and_fix(Main *bmain) ATTR_NONNULL()
void BKE_main_namemap_clear(Main *bmain) ATTR_NONNULL()
General operations, lookup, etc. for materials.
void BKE_object_materials_test(struct Main *bmain, struct Object *ob, struct ID *id)
General operations, lookup, etc. for blender objects.
void BKE_packedfile_blend_read(BlendDataReader *reader, PackedFile **pf_p, blender::StringRefNull filepath)
void BKE_preferences_extension_repo_read_data(struct BlendDataReader *reader, bUserExtensionRepo *repo)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
const char * BKE_report_type_str(eReportType type)
void BKE_report(ReportList *reports, eReportType type, const char *message)
bool BKE_screen_blend_read_data(BlendDataReader *reader, bScreen *screen)
#define BLI_assert_unreachable()
#define BLI_STATIC_ASSERT(a, msg)
#define BLI_assert_msg(a, msg)
BLI_INLINE void BLI_endian_switch_uint64(uint64_t *val) ATTR_NONNULL(1)
void BLI_endian_switch_float_array(float *val, int size) ATTR_NONNULL(1)
BLI_INLINE void BLI_endian_switch_int32(int *val) ATTR_NONNULL(1)
void BLI_endian_switch_int32_array(int *val, int size) ATTR_NONNULL(1)
void BLI_endian_switch_uint32_array(unsigned int *val, int size) ATTR_NONNULL(1)
void BLI_endian_switch_double_array(double *val, int size) ATTR_NONNULL(1)
bool BLI_file_magic_is_gzip(const char header[4])
bool BLI_file_magic_is_zstd(const char header[4])
int BLI_open(const char *filepath, int oflag, int pmode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
FileReader * BLI_filereader_new_mmap(int filedes) ATTR_WARN_UNUSED_RESULT
FileReader * BLI_filereader_new_zstd(FileReader *base) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
FileReader * BLI_filereader_new_file(int filedes) ATTR_WARN_UNUSED_RESULT
FileReader * BLI_filereader_new_gzip(FileReader *base) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
FileReader * BLI_filereader_new_memory(const void *data, size_t len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_ghash_haskey(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
GHash * BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GHash * BLI_ghash_str_new_ex(const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
void void void BLI_movelisttolist(struct ListBase *dst, struct ListBase *src) ATTR_NONNULL(1
bool BLI_remlink_safe(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void void BLI_INLINE bool BLI_listbase_is_single(const struct ListBase *lb)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1)
struct MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
#define BLI_MEMARENA_STD_BUFSIZE
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
int BLI_path_normalize(char *path) ATTR_NONNULL(1)
bool BLI_path_is_rel(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
bool void BLI_path_rel(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1)
#define STRNCPY(dst, src)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
Platform independent time functions.
double BLI_time_now_seconds(void)
#define STREQLEN(a, b, n)
#define UNUSED_VARS_NDEBUG(...)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define POINTER_OFFSET(v, ofs)
Compatibility-like things for windows.
defines for blend-file codes.
#define BLEN_THUMB_MEMSIZE_FILE(_x, _y)
Utilities ensuring .blend file (i.e. Main) is in valid state during write and/or read process.
void BLO_main_validate_embedded_flag(Main *bmain, ReportList *reports)
bool BLO_main_validate_shapekeys(Main *bmain, ReportList *reports)
void BLO_main_validate_embedded_liboverrides(Main *bmain, ReportList *reports)
#define BLO_read_data_address(reader, ptr_p)
#define BLO_read_struct_list(reader, struct_name, list)
#define BLO_read_struct(reader, struct_name, ptr_p)
external readfile function prototypes.
void(*)(void *fdhandle, Main *mainvar, void *idv) BLOExpandDoitCallback
@ BLO_LIBLINK_USE_PLACEHOLDERS
@ BLO_LIBLINK_FORCE_INDIRECT
@ BLO_READ_SKIP_UNDO_OLD_MAIN
FileReader * BLO_memfile_new_filereader(MemFile *memfile, int undo_direction)
#define CLOG_ERROR(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
#define CLOG_INFO(clg_ref, level,...)
#define ID_FAKE_USERS(id)
#define ID_IS_LINKED(_id)
@ ID_FLAG_INDIRECT_WEAK_LINK
@ ID_TAG_UNDO_OLD_ID_REUSED_UNCHANGED
@ ID_TAG_UNDO_OLD_ID_REUSED_NOUNDO
@ ID_TAG_UNDO_OLD_ID_REREAD_IN_PLACE
@ ID_TAG_LIBOVERRIDE_NEED_RESYNC
@ ID_TAG_ID_LINK_PLACEHOLDER
@ LIBRARY_IS_ASSET_EDIT_FILE
#define ID_TAG_KEEP_ON_UNDO
#define ID_LINK_PLACEHOLDER
Object groups, one object can be in many groups at once.
blenloader genfile private function prototypes
const char * DNA_struct_get_compareflags(const struct SDNA *oldsdna, const struct SDNA *newsdna)
void DNA_sdna_free(struct SDNA *sdna)
const struct SDNA * DNA_sdna_current_get(void)
int DNA_struct_find_with_alias(const struct SDNA *sdna, const char *str)
int DNA_struct_member_offset_by_name_with_alias(const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
int DNA_struct_size(const struct SDNA *sdna, int struct_index)
const char * DNA_struct_identifier(struct SDNA *sdna, int struct_index)
void * DNA_struct_reconstruct(const struct DNA_ReconstructInfo *reconstruct_info, int old_struct_index, int blocks, const void *old_blocks, const char *alloc_name)
struct DNA_ReconstructInfo * DNA_reconstruct_info_create(const struct SDNA *oldsdna, const struct SDNA *newsdna, const char *compare_flags)
struct SDNA * DNA_sdna_from_data(const void *data, int data_len, bool do_endian_swap, bool data_alloc, bool do_alias, const char **r_error_message)
void DNA_struct_switch_endian(const struct SDNA *sdna, int struct_index, char *data)
void DNA_reconstruct_info_free(struct DNA_ReconstructInfo *reconstruct_info)
int DNA_struct_alignment(const struct SDNA *sdna, int struct_index)
void DNA_sdna_alias_data_ensure_structs_map(struct SDNA *sdna)
@ SCE_READFILE_LIBLINK_NEED_SETSCENE_CHECK
#define SDNA_RAW_DATA_STRUCT_INDEX
@ USER_MENU_TYPE_OPERATOR
DrawDataList * DRW_drawdatalist_from_id(ID *id)
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert * v2
const Value * lookup_ptr(const Key &key) const
bool add_overwrite(const Key &key, const Value &value)
bool add(const Key &key, const Value &value)
Value lookup_default(const Key &key, const Value &default_value) const
ValueIterator values() const
const char * insert(const keyT &key, std::string alloc_string)
bool contains(const keyT &key)
const char * find(const keyT &key)
DEGForeachIDComponentCallback callback
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
#define pf(_x, _i)
Prefetch 64.
void * MEM_mallocN_aligned(size_t len, size_t alignment, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
size_t(* MEM_allocN_len)(const void *vmemh)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void node_tree_blend_read_data(BlendDataReader *reader, ID *owner_id, bNodeTree *ntree)
void node_tree_update_all_new(Main *main)
bNodeTree ** node_tree_ptr_from_id(ID *id)
bNodeTree * node_tree_from_id(ID *id)
AllocStringStorage< keyT, hashT > & alloc_string_storage_get(const std::string &storage_identifier)
void blo_do_versions_oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void *newaddr, int nr)
static int lib_link_cb(LibraryIDLinkCallbackData *cb_data)
void BLO_read_float3_array(BlendDataReader *reader, int array_size, float **ptr_p)
static BHead * find_bhead(FileData *fd, void *old)
static void * newdataadr_no_us(FileData *fd, const void *adr)
static void read_libraries(FileData *basefd, ListBase *mainlist)
void * blo_do_versions_newlibadr(FileData *fd, ID *self_id, const bool is_linked_only, const void *adr)
static void lib_link_scenes_check_set(Main *bmain)
void BLO_read_struct_list_with_size(BlendDataReader *reader, const size_t expected_elem_size, ListBase *list)
static bool read_libblock_undo_restore_library(FileData *fd, Main *new_main, const ID *id, ID *id_old, BHead *bhead)
FileData * blo_filedata_from_memory(const void *mem, int memsize, BlendFileReadReport *reports)
static void link_glob_list(FileData *fd, ListBase *lb)
static void bh8_from_bh4(BHead *bhead, BHead4 *bhead4)
static ID * create_placeholder(Main *mainvar, const short idcode, const char *idname, const int tag, const bool was_liboverride)
static FileData * blo_filedata_from_file_descriptor(const char *filepath, BlendFileReadReport *reports, int filedes)
static void lib_link_all(FileData *fd, Main *bmain)
void blo_cache_storage_end(FileData *fd)
static FileData * filedata_new(BlendFileReadReport *reports)
BlendThumbnail * BLO_thumbnail_from_file(const char *filepath)
static void direct_link_library(FileData *fd, Library *lib, Main *main)
static void convert_pointer_array_64_to_32(BlendDataReader *reader, uint array_size, const uint64_t *src, uint32_t *dst)
static void read_file_bhead_idname_map_create(FileData *fd)
static int direct_link_id_restore_recalc_exceptions(const ID *id_current)
void BLO_read_uint8_array(BlendDataReader *reader, int array_size, uint8_t **ptr_p)
void BLO_library_link_params_init(LibraryLink_Params *params, Main *bmain, const int flag, const int id_tag_extra)
static void split_main_newid(Main *mainptr, Main *main_newid)
static void link_global(FileData *fd, BlendFileData *bfd)
static BHead * read_global(BlendFileData *bfd, FileData *fd, BHead *bhead)
int BLO_read_fileversion_get(BlendDataReader *reader)
BHead * blo_bhead_next(FileData *fd, BHead *thisblock)
blender::ImplicitSharingInfoAndData blo_read_shared_impl(BlendDataReader *reader, const void **ptr_p, const blender::FunctionRef< const blender::ImplicitSharingInfo *()> read_fn)
static void read_undo_reuse_noundo_local_ids(FileData *fd)
BlendFileReadReport * BLO_read_data_reports(BlendDataReader *reader)
BHead * blo_bhead_first(FileData *fd)
static bool read_libblock_is_identical(FileData *fd, BHead *bhead)
Main * BLO_read_lib_get_main(BlendLibReader *reader)
static BHead * read_libblock(FileData *fd, Main *main, BHead *bhead, int id_tag, const bool placeholder_set_indirect_extern, ID **r_id)
static void direct_link_id_common(BlendDataReader *reader, Library *current_library, ID *id, ID *id_old, const int id_tag)
static int direct_link_id_restore_recalc(const FileData *fd, const ID *id_target, const ID *id_current, const bool is_identical)
static bool blo_bhead_is_id(const BHead *bhead)
static void direct_link_id_override_property(BlendDataReader *reader, IDOverrideLibraryProperty *op)
static const char * library_parent_filepath(Library *lib)
static void direct_link_id_embedded_id(BlendDataReader *reader, Library *current_library, ID *id, ID *id_old)
void BLO_read_glob_list(BlendDataReader *reader, ListBase *list)
static int has_linked_ids_to_read(Main *mainvar)
static BHead * blo_bhead_read_full(FileData *fd, BHead *thisblock)
static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *id_old)
static void library_link_end(Main *mainl, FileData **fd, const int flag)
static void do_versions_userdef(FileData *, BlendFileData *bfd)
static void split_libdata(ListBase *lb_src, Main **lib_main_array, const uint lib_main_array_len)
void BLO_read_double_array(BlendDataReader *reader, int array_size, double **ptr_p)
static void add_main_to_main(Main *mainvar, Main *from)
static OldNewMap * oldnewmap_new()
static void after_liblink_id_process(BlendLibReader *reader, ID *id)
bool BLO_read_data_is_undo(BlendDataReader *reader)
static bool read_libblock_undo_restore_linked(FileData *fd, Main *libmain, const ID *id, ID **r_id_old, BHead *bhead)
static void * newdataadr(FileData *fd, const void *adr)
void * BLO_read_get_new_data_address_no_us(BlendDataReader *reader, const void *old_address, const size_t expected_size)
void * BLO_read_struct_by_name_array(BlendDataReader *reader, const char *struct_name, const uint32_t items_num, const void *old_address)
static void do_versions_after_linking(FileData *fd, Main *main)
ID * BLO_read_get_new_id_address_from_session_uid(BlendLibReader *reader, uint session_uid)
void BLO_read_float_array(BlendDataReader *reader, int array_size, float **ptr_p)
void BLO_read_int32_array(BlendDataReader *reader, int array_size, int32_t **ptr_p)
static bool oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void *newaddr, int nr)
static BHead * read_data_into_datamap(FileData *fd, BHead *bhead, const char *allocname, const int id_type_index)
ID * BLO_read_get_new_id_address(BlendLibReader *reader, ID *self_id, const bool is_linked_only, ID *id)
static BHead * find_bhead_from_idname(FileData *fd, const char *idname)
BlendFileReadReport * BLO_read_lib_reports(BlendLibReader *reader)
static const char * get_alloc_name(FileData *fd, BHead *bh, const char *blockname, int id_type_index=INDEX_ID_NULL)
AssetMetaData * blo_bhead_id_asset_data_address(const FileData *fd, const BHead *bhead)
BlendFileData * blo_read_file_internal(FileData *fd, const char *filepath)
static void switch_endian_structs(const SDNA *filesdna, BHead *bhead)
static void sort_bhead_old_map(FileData *fd)
FileData * blo_filedata_from_memfile(MemFile *memfile, const BlendFileReadParams *params, BlendFileReadReport *reports)
static void fix_relpaths_library(const char *basepath, Main *main)
static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
void BLO_read_pointer_array(BlendDataReader *reader, const int array_size, void **ptr_p)
static void blo_cache_storage_entry_clear_in_old(ID *, const IDCacheKey *key, void **cache_p, uint, void *cache_storage_v)
bool BLO_read_lib_is_undo(BlendLibReader *reader)
void * BLO_read_struct_array_with_size(BlendDataReader *reader, const void *old_address, const size_t expected_size)
static const void * peek_struct_undo(FileData *fd, BHead *bhead)
static void * oldnewmap_liblookup(OldNewMap *onm, const void *addr, const bool is_linked_only)
static void oldnewmap_free(OldNewMap *onm)
void BLO_read_uint32_array(BlendDataReader *reader, int array_size, uint32_t **ptr_p)
static BHeadN * get_bhead(FileData *fd)
static ID * link_named_part(Main *mainl, FileData *fd, const short idcode, const char *name, const int flag)
static void after_liblink_merged_bmain_process(Main *bmain, BlendFileReadReport *reports)
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
void BLO_read_data_globmap_add(BlendDataReader *reader, void *oldaddr, void *newaddr)
static bool read_libblock_undo_restore(FileData *fd, Main *main, BHead *bhead, int id_tag, ID **r_id_old)
static int expand_cb(LibraryIDLinkCallbackData *cb_data)
const char * blo_bhead_id_name(const FileData *fd, const BHead *bhead)
static void read_undo_remap_noundo_data(FileData *fd)
FileData * blo_filedata_from_file(const char *filepath, BlendFileReadReport *reports)
static void read_library_linked_id(FileData *basefd, FileData *fd, Main *mainvar, ID *id, ID **r_id)
static void read_library_linked_ids(FileData *basefd, FileData *fd, ListBase *mainlist, Main *mainvar)
static void do_versions(FileData *fd, Library *lib, Main *main)
#define BHEADN_FROM_BHEAD(bh)
static void change_link_placeholder_to_real_ID_pointer_fd(FileData *fd, const void *old, void *newp)
void BLO_read_char_array(BlendDataReader *reader, int array_size, char **ptr_p)
Main * BLO_library_link_begin(BlendHandle **bh, const char *filepath, const LibraryLink_Params *params)
bool BLO_read_requires_endian_switch(BlendDataReader *reader)
static ID * library_id_is_yet_read(FileData *fd, Main *mainvar, BHead *bhead)
static void blo_cache_storage_entry_restore_in_new(ID *id, const IDCacheKey *key, void **cache_p, uint flags, void *cache_storage_v)
static void direct_link_keymapitem(BlendDataReader *reader, wmKeyMapItem *kmi)
static void blo_cache_storage_entry_register(ID *id, const IDCacheKey *key, void **cache_p, uint, void *cache_storage_v)
static void * newlibadr(FileData *fd, ID *, const bool is_linked_only, const void *adr)
void blo_split_main(ListBase *mainlist, Main *main)
static int verg_bheadsort(const void *v1, const void *v2)
void BLO_library_link_params_init_with_context(LibraryLink_Params *params, Main *bmain, const int flag, const int id_tag_extra, Scene *scene, ViewLayer *view_layer, const View3D *v3d)
static bool read_file_dna(FileData *fd, const char **r_error_message)
void blo_do_versions_key_uidgen(Key *key)
static void placeholders_ensure_valid(Main *bmain)
static BHead * find_bhead_from_code_name(FileData *fd, const short idcode, const char *name)
void blo_cache_storage_init(FileData *fd, Main *bmain)
void blo_make_old_idmap_from_main(FileData *fd, Main *bmain)
short BLO_version_from_file(const char *filepath)
BHead * blo_read_asset_data_block(FileData *fd, BHead *bhead, AssetMetaData **r_asset_data)
static void read_libblock_undo_restore_identical(FileData *fd, Main *main, const ID *, ID *id_old, BHead *bhead, const int id_tag)
static void change_link_placeholder_to_real_ID_pointer(ListBase *mainlist, FileData *basefd, void *old, void *newp)
static FileData * blo_filedata_from_file_minimal(const char *filepath)
static void oldnewmap_clear(OldNewMap *onm)
static void decode_blender_header(FileData *fd)
static void read_libblock_undo_restore_at_old_address(FileData *fd, Main *main, ID *id, ID *id_old)
static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, bool do_endian_swap)
void BLO_reportf_wrap(BlendFileReadReport *reports, eReportType type, const char *format,...)
static void * oldnewmap_lookup_and_inc(OldNewMap *onm, const void *addr, bool increase_users)
static BHead * find_previous_lib(FileData *fd, BHead *bhead)
#define BHEAD_USE_READ_ON_DEMAND(bhead)
static void read_library_clear_weak_links(FileData *basefd, ListBase *mainlist, Main *mainvar)
void * BLO_library_read_struct(FileData *fd, BHead *bh, const char *blockname)
static bool is_minversion_older_than_blender(FileData *fd, ReportList *reports)
void BLO_expand_main(void *fdhandle, Main *mainvar, BLOExpandDoitCallback callback)
void * BLO_read_get_new_data_address(BlendDataReader *reader, const void *old_address)
static void switch_endian_bh4(BHead4 *bhead)
static Main * library_link_begin(Main *mainvar, FileData *fd, const char *filepath, const int id_tag_extra)
static void blo_read_file_checks(Main *bmain)
static void switch_endian_bh8(BHead8 *bhead)
ID * BLO_library_link_named_part(Main *mainl, BlendHandle **bh, const short idcode, const char *name, const LibraryLink_Params *params)
static bool blo_bhead_read_data(FileData *fd, BHead *thisblock, void *buf)
static Main * blo_find_main(FileData *fd, const char *filepath, const char *relabase)
static BHead * read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
void blo_filedata_free(FileData *fd)
static int * read_file_thumbnail(FileData *fd)
static bool blo_bhead_is_id_valid_type(const BHead *bhead)
static void after_liblink_id_embedded_id_process(BlendLibReader *reader, ID *id)
BHead * blo_bhead_prev(FileData *, BHead *thisblock)
static void read_undo_move_libmain_data(FileData *fd, Main *new_main, Main *old_main, Main *libmain, BHead *bhead)
static void oldnewmap_lib_insert(FileData *fd, const void *oldaddr, ID *newaddr, int id_code)
void BLO_read_int8_array(BlendDataReader *reader, int array_size, int8_t **ptr_p)
void blo_readfile_invalidate(FileData *fd, Main *bmain, const char *message)
void BLO_library_link_end(Main *mainl, BlendHandle **bh, const LibraryLink_Params *params)
static void read_file_version(FileData *fd, Main *main)
void blo_cache_storage_old_bmain_clear(FileData *fd, Main *bmain_old)
static CLG_LogRef LOG_UNDO
static FileData * blo_filedata_from_file_open(const char *filepath, BlendFileReadReport *reports)
static int read_undo_remap_noundo_data_cb(LibraryIDLinkCallbackData *cb_data)
static void * blo_verify_data_address(void *new_address, const void *, const size_t expected_size)
static void * read_struct(FileData *fd, BHead *bh, const char *blockname, const int id_type_index)
void blo_join_main(ListBase *mainlist)
static void convert_pointer_array_32_to_64(BlendDataReader *, uint array_size, const uint32_t *src, uint64_t *dst)
static FileData * blo_decode_and_check(FileData *fd, ReportList *reports)
void * blo_read_get_new_globaldata_address(FileData *fd, const void *adr)
static FileData * read_library_file_data(FileData *basefd, ListBase *mainlist, Main *mainl, Main *mainptr)
void blo_do_versions_400(FileData *fd, Library *lib, Main *bmain)
void blo_do_versions_300(FileData *fd, Library *lib, Main *bmain)
void do_versions_after_linking_300(FileData *fd, Main *bmain)
void blo_do_versions_dna(SDNA *sdna, int versionfile, int subversionfile)
void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
void do_versions_after_linking_400(FileData *fd, Main *bmain)
void do_versions_after_linking_250(Main *bmain)
void do_versions_after_linking_290(FileData *fd, Main *bmain)
@ FD_FLAGS_FILE_POINTSIZE_IS_4
@ FD_FLAGS_POINTSIZE_DIFFERS
void blo_do_versions_userdef(UserDef *userdef)
void do_versions_after_linking_280(FileData *fd, Main *bmain)
void blo_do_versions_290(FileData *fd, Library *lib, Main *bmain)
void blo_do_versions_270(FileData *fd, Library *lib, Main *bmain)
void do_versions_after_linking_270(Main *bmain)
void do_versions_after_linking_260(Main *bmain)
void blo_do_versions_260(FileData *fd, Library *lib, Main *bmain)
#define SIZEOFBLENDERHEADER
void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
void blo_do_versions_280(FileData *fd, Library *lib, Main *bmain)
unsigned __int64 uint64_t
bool is_memchunk_identical
blender::Map< const void *, blender::ImplicitSharingInfoAndData > shared_data_by_stored_address
BLOExpandDoitCallback callback
ViewLayer * cur_view_layer
struct BlendFileReadReport::@127 duration
struct BlendFileReadReport::@128 count
GHash * bhead_idname_hash
DNA_ReconstructInfo * reconstruct_info
IDNameLib_Map * new_idmap_uid
BLOCacheStorage * cache_storage
BlendFileReadReport * reports
IDNameLib_Map * old_idmap_uid
struct ViewLayer * cur_view_layer
uint64_t build_commit_timestamp
struct bScreen * curscreen
unsigned int id_session_uid
IDTypeBlendReadUndoPreserve blend_read_undo_preserve
IDTypeForeachCacheFunction foreach_cache
IDTypeBlendReadDataFunction blend_read_data
AssetTypeInfo * asset_type_info
IDTypeBlendReadAfterLiblinkFunction blend_read_after_liblink
unsigned int recalc_after_undo_push
unsigned int recalc_up_to_undo_push
struct FileData * filedata
struct PackedFile * packedfile
struct Library_Runtime runtime
bool has_forward_compatibility_issues
BlendThumbnail * blen_thumb
uint64_t build_commit_timestamp
blender::Map< const void *, const blender::ImplicitSharingInfo * > map
MemFileSharedStorage * shared_storage
blender::Map< const void *, NewAddress > map
ListBase script_directories
struct ListBase asset_shelves_settings
struct ListBase user_keymaps
struct ListBase autoexec_paths
struct ListBase user_keyconfig_prefs
struct ListBase extension_repos
struct ListBase user_menus
struct ListBase asset_libraries
static DynamicLibrary lib