Blender V5.3
readfile.cc File Reference
#include "fmt/core.h"
#include <algorithm>
#include <cerrno>
#include <climits>
#include <cstdarg>
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fcntl.h>
#include <queue>
#include <unistd.h>
#include <fmt/format.h>
#include "CLG_log.h"
#include "DNA_asset_types.h"
#include "DNA_collection_types.h"
#include "DNA_constraint_types.h"
#include "DNA_fileglobal_types.h"
#include "DNA_genfile.h"
#include "DNA_key_types.h"
#include "DNA_layer_types.h"
#include "DNA_node_types.h"
#include "DNA_packedFile_types.h"
#include "DNA_screen_types.h"
#include "DNA_sdna_types.h"
#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
#include "MEM_alloc_string_storage.hh"
#include "MEM_guardedalloc.h"
#include "MEM_safe_multiply.h"
#include "BLI_endian_defines.hh"
#include "BLI_fileops.hh"
#include "BLI_ghash.hh"
#include "BLI_listbase.hh"
#include "BLI_map.hh"
#include "BLI_memarena.hh"
#include "BLI_memory_utils.hh"
#include "BLI_set.hh"
#include "BLI_string.hh"
#include "BLI_string_ref.hh"
#include "BLI_string_utf8.hh"
#include "BLI_string_utils.hh"
#include "BLI_threads.hh"
#include "BLI_time.hh"
#include "BLI_utildefines.hh"
#include "BLT_translation.hh"
#include "BKE_anim_data.hh"
#include "BKE_animsys.hh"
#include "BKE_asset.hh"
#include "BKE_blender_version.h"
#include "BKE_collection.hh"
#include "BKE_global.hh"
#include "BKE_idprop.hh"
#include "BKE_idtype.hh"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_override.hh"
#include "BKE_lib_query.hh"
#include "BKE_lib_remap.hh"
#include "BKE_library.hh"
#include "BKE_main.hh"
#include "BKE_main_idmap.hh"
#include "BKE_main_invariants.hh"
#include "BKE_main_namemap.hh"
#include "BKE_material.hh"
#include "BKE_mesh.hh"
#include "BKE_modifier.hh"
#include "BKE_nla.hh"
#include "BKE_node.hh"
#include "BKE_node_tree_update.hh"
#include "BKE_object.hh"
#include "BKE_packedFile.hh"
#include "BKE_preferences.h"
#include "BKE_report.hh"
#include "BKE_scene.hh"
#include "BKE_screen.hh"
#include "BKE_undo_system.hh"
#include "BKE_workspace.hh"
#include "DRW_engine.hh"
#include "DEG_depsgraph.hh"
#include "BLO_blend_validate.hh"
#include "BLO_core_file_reader.hh"
#include "BLO_read_write.hh"
#include "BLO_readfile.hh"
#include "BLO_undofile.hh"
#include "SEQ_iterator.hh"
#include "SEQ_modifier.hh"
#include "SEQ_sequencer.hh"
#include "SEQ_utils.hh"
#include "IMB_colormanagement.hh"
#include "readfile.hh"
#include "versioning_common.hh"

Go to the source code of this file.

Classes

struct  blender::BHeadN
struct  blender::NewAddress
struct  blender::OldNewMap
struct  blender::BLOCacheStorage
struct  blender::BLOCacheStorageValue
struct  blender::BHeadSort
struct  blender::BlendExpander

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define DNA_DEPRECATED_ALLOW
#define U   (*((const UserDef *)&U))
#define USE_BHEAD_READ_ON_DEMAND
#define BHEADN_FROM_BHEAD(bh)
#define BHEAD_USE_READ_ON_DEMAND(bhead)

Functions

static void blender::read_libraries_free_placeholders (FileData *basefd)
static void * blender::read_struct_and_validate_size (FileData *fd, BHead *bh, const char *blockname, const int id_type_index, const int64_t min_size)
Library Reading
static void blender::read_libraries (FileData *basefd)
static int blender::has_linked_ids_to_read (Main *mainvar)
static void blender::read_library_linked_id (FileData *basefd, FileData *fd, Main *mainvar, ID *id, ID **r_id)
static void blender::read_library_linked_ids (FileData *basefd, FileData *fd, Main *mainvar)
static void blender::read_library_clear_weak_links (FileData *basefd, Main *mainvar)
static FileData * blender::read_library_file_data (FileData *basefd, Main *bmain, Main *lib_bmain)
static void * blender::blo_verify_data_address (FileData *fd, void *new_address, const void *, const int64_t alloc_len, const size_t expected_size)
static void * blender::blo_check_data_address_nonnull (FileData *fd, const void *old_address, void *new_address)
static bool blender::blo_read_verify_type_size (FileData *fd, NewAddress &entry, const void *old_address, FunctionRef< size_t(const void *data)> type_size_fn)
static void blender::convert_pointer_array_64_to_32 (BlendDataReader *reader, const int64_t array_size, const uint64_t *src, uint32_t *dst)
static void blender::convert_pointer_array_32_to_64 (BlendDataReader *, const int64_t array_size, const uint32_t *src, uint64_t *dst)
ImplicitSharingInfoAndData blender::blo_read_shared_impl (BlendDataReader *reader, const void **ptr_p, const FunctionRef< const ImplicitSharingInfo *()> read_fn)
DNA Struct Loading
static void * blender::read_struct (FileData *fd, BHead *bh, const char *blockname, const int id_type_index, int64_t *r_alloc_len=nullptr)
static const char * blender::get_alloc_name (FileData *fd, BHead *bh, const char *blockname, const int id_type_index=INDEX_ID_NULL)
static ID * blender::read_id_struct (FileData *fd, BHead *bh, const char *blockname, const int id_type_index)
static const void * blender::peek_struct_undo (FileData *fd, BHead *bhead)
static void blender::link_glob_list (FileData *fd, ListBase *lb)
Library Linking

Also used for append.

static BHead * blender::find_bhead_from_code_name (FileData *fd, const short idcode, const char *name)
static int blender::verg_bheadsort (const void *v1, const void *v2)
static void blender::sort_bhead_old_map (FileData *fd)
static BHead * blender::find_previous_lib (FileData *fd, BHead *bhead)
static Library * blender::read_library_struct (FileData *fd, BHead *bheadlib)
static BHead * blender::find_bhead (FileData *fd, void *old)
static BHead * blender::find_bhead_from_idname (FileData *fd, const char *idname)
static ID * blender::library_id_is_yet_read_deep_hash (FileData *fd, BHead *bhead)
static ID * blender::library_id_is_yet_read_main (Main *mainvar, const char *idname)
static void blender::read_libraries_report_invalid_id_names (FileData *fd, ReportList *reports, const bool has_forward_compatibility_issues, const char *filepath)
Report API
void blender::BLO_reportf_wrap (BlendFileReadReport *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Blend Loader Reporting Wrapper
static const char * blender::library_parent_filepath (Library *lib)
OldNewMap API
static OldNewMap * blender::oldnewmap_new ()
static bool blender::oldnewmap_insert (OldNewMap *onm, const void *oldaddr, void *newaddr, const int nr, const int64_t alloc_len=0)
static void blender::oldnewmap_lib_insert (FileData *fd, const void *oldaddr, ID *newaddr, const int id_code)
void blender::blo_do_versions_oldnewmap_insert (OldNewMap *onm, const void *oldaddr, void *newaddr, const int nr)
static void * blender::oldnewmap_lookup_and_inc (OldNewMap *onm, const void *addr, const bool increase_users, int64_t *r_alloc_len=nullptr)
static void * blender::oldnewmap_liblookup (OldNewMap *onm, const void *addr, const bool is_linked_only)
static void blender::oldnewmap_clear (OldNewMap *onm)
static void blender::oldnewmap_free (OldNewMap *onm)
Helper Functions
static void blender::add_main_to_main (Main *mainvar, Main *from)
void blender::blo_join_main (Main *bmain)
static void blender::split_libdata (ListBaseT< ID > *lb_src, Vector< Main * > &lib_main_array, const bool do_split_packed_ids)
void blender::blo_split_main (Main *bmain, const bool do_split_packed_ids)
static void blender::read_file_version_and_colorspace (FileData *fd, Main *main)
static bool blender::blo_bhead_is_id (const BHead *bhead)
static bool blender::blo_bhead_is_id_valid_type (const BHead *bhead)
static void blender::read_file_bhead_idname_map_create (FileData *fd)
void blender::blo_readfile_invalidate (FileData *fd, Main *bmain, const char *message)
File Parsing
static BHeadN * blender::get_bhead (FileData *fd)
BHead * blender::blo_bhead_first (FileData *fd)
BHead * blender::blo_bhead_prev (FileData *, BHead *thisblock)
BHead * blender::blo_bhead_next (FileData *fd, BHead *thisblock)
static bool blender::blo_bhead_read_data (FileData *fd, BHead *thisblock, void *buf)
static BHead * blender::blo_bhead_read_full (FileData *fd, BHead *thisblock)
template<typename T>
static const T * blender::blo_bhead_data_at (const BHead *bhead, const int offset)
static const char * blender::blo_bhead_string_at (const BHead *bhead, const int offset, const size_t maxsize)
const char * blender::blo_bhead_id_name (FileData *fd, const BHead *bhead)
short blender::blo_bhead_id_flag (const FileData *fd, const BHead *bhead)
AssetMetaData * blender::blo_bhead_id_asset_data_address (const FileData *fd, const BHead *bhead)
static const IDHash * blender::blo_bhead_id_deep_hash (const FileData *fd, const BHead *bhead)
const char * blender::blo_bhead_library_filepath (const FileData *fd, const BHead *bhead)
LibraryFlag blender::blo_bhead_library_flag (const FileData *fd, const BHead *bhead)
static void blender::read_blender_header (FileData *fd)
static bool blender::read_file_dna (FileData *fd, const char **r_error_message)
static int * blender::read_file_thumbnail (FileData *fd)
static void blender::long_id_names_ensure_unique_id_names (Main *bmain)
static void blender::long_id_names_process_action_slots_identifiers (Main *bmain)
File Data API
static FileData * blender::filedata_new (BlendFileReadReport *reports)
static bool blender::is_minversion_older_than_blender (FileData *fd, ReportList *reports)
static FileData * blender::blo_decode_and_check (FileData *fd, ReportList *reports)
static FileData * blender::blo_filedata_from_file_descriptor (const char *filepath, BlendFileReadReport *reports, const int filedes)
static FileData * blender::blo_filedata_from_file_open (const char *filepath, BlendFileReadReport *reports)
FileData * blender::blo_filedata_from_file (const char *filepath, BlendFileReadReport *reports)
static FileData * blender::blo_filedata_from_file_minimal (const char *filepath)
FileData * blender::blo_filedata_from_memory (const void *mem, const int memsize, BlendFileReadReport *reports)
FileData * blender::blo_filedata_from_memfile (MemFile *memfile, const BlendFileReadParams *params, BlendFileReadReport *reports)
void blender::blo_filedata_free (FileData *fd)
Read Thumbnail from Blend File
BlendThumbnail * blender::BLO_thumbnail_from_file (const char *filepath)
short blender::BLO_version_from_file (const char *filepath)
Old/New Pointer Map
static void * blender::newdataadr (FileData *fd, const void *adr, int64_t *r_alloc_len=nullptr)
static void * blender::newdataadr_no_us (FileData *fd, const void *adr, int64_t *r_alloc_len=nullptr)
static NewAddress * blender::newdataadr_entry (FileData *fd, const void *adr)
void * blender::blo_read_get_new_globaldata_address (FileData *fd, const void *adr)
static void * blender::newlibadr (FileData *fd, ID *, const bool is_linked_only, const void *adr)
void * blender::blo_do_versions_newlibadr (FileData *fd, ID *self_id, const bool is_linked_only, const void *adr)
static void blender::change_link_placeholder_to_real_ID_pointer_fd (FileData *fd, const void *old, void *newp)
static void blender::change_ID_pointer_to_real_ID_pointer_fd (FileData *fd, const void *old, void *newp)
static FileData * blender::change_ID_link_filedata_get (Main *bmain, FileData *basefd)
static void blender::change_link_placeholder_to_real_ID_pointer (FileData *basefd, const void *old, void *newp)
static void blender::change_ID_pointer_to_real_ID_pointer (FileData *basefd, const void *old, void *newp)
void blender::blo_make_old_idmap_from_main (FileData *fd, Main *bmain)
static void blender::blo_cache_storage_entry_register (ID *id, const IDCacheKey *key, void **cache_p, uint, void *cache_storage_v)
static void blender::blo_cache_storage_entry_restore_in_new (ID *id, const IDCacheKey *key, void **cache_p, const uint flags, void *cache_storage_v)
static void blender::blo_cache_storage_entry_clear_in_old (ID *, const IDCacheKey *key, void **cache_p, const uint, void *cache_storage_v)
void blender::blo_cache_storage_init (FileData *fd, Main *bmain)
void blender::blo_cache_storage_old_bmain_clear (FileData *fd, Main *bmain_old)
void blender::blo_cache_storage_end (FileData *fd)
Read ID
static void blender::after_liblink_id_process (BlendLibReader *reader, ID *id)
static void blender::after_liblink_id_embedded_id_process (BlendLibReader *reader, ID *id)
static void blender::direct_link_id_override_property (BlendDataReader *reader, IDOverrideLibraryProperty *op)
static void blender::direct_link_id_common (BlendDataReader *reader, Library *current_library, ID *id, ID *id_old, eID_Tag id_tag, ID_Readfile_Data::Tags id_read_tags)
static void blender::direct_link_id_embedded_id (BlendDataReader *reader, Library *current_library, ID *id, ID *id_old)
static int blender::direct_link_id_restore_recalc_exceptions (const ID *id_current)
static int blender::direct_link_id_restore_recalc (const FileData *fd, const ID *id_target, const ID *id_current, const bool is_identical)
static void blender::readfile_id_runtime_data_ensure (ID &id)
ID_Readfile_Data::Tags blender::BLO_readfile_id_runtime_tags (const ID &id)
ID_Readfile_Data::Tags & blender::BLO_readfile_id_runtime_tags_for_write (ID &id)
void blender::BLO_readfile_id_runtime_data_free (ID &id)
void blender::BLO_readfile_id_runtime_data_free_all (Main &bmain)
Read ID: Shape Keys
void blender::blo_do_versions_key_uidgen (Key *key)
Read ID: Scene
static void blender::lib_link_scenes_check_set (Main *bmain)
Read ID: Library
static void blender::library_filedata_release (Library *lib)
static Main * blender::blo_add_main_for_library (FileData *fd, const BHead *bheadlib, Library *lib, Library *reference_lib, const char *lib_filepath, char(&filepath_abs)[FILE_MAX], const bool is_packed_library, const bool is_external_lib)
static bool blender::library_filepath_is_valid (const Library *lib)
static void blender::direct_link_library (FileData *fd, Library *lib, Main *main)
static void blender::fix_relpaths_library (const char *basepath, Main *main)
Read Library Data Block
static ID * blender::create_placeholder (Main *mainvar, const short idcode, const char *idname, const int tag, const bool was_liboverride)
static void blender::placeholders_ensure_valid (Main *bmain)
static bool blender::direct_link_id (FileData *fd, Main *main, const eID_Tag id_tag, const ID_Readfile_Data::Tags id_read_tags, ID *id, ID *id_old)
static BHead * blender::read_data_into_datamap (FileData *fd, BHead *bhead, const char *allocname, const int id_type_index)
static bool blender::read_libblock_is_identical (FileData *fd, BHead *bhead)
static void blender::read_undo_tag_all_noundo_ids (FileData *fd)
static void blender::read_undo_reuse_noundo_local_ids (FileData *fd)
static void blender::read_undo_move_libmain_data (FileData *fd, Main *libmain, BHead *bhead)
static bool blender::read_libblock_undo_restore_library (FileData *fd, const ID *id, ID *id_old, BHead *bhead)
static void blender::read_undo_libraries_preserve_never_undo_libraries (FileData *fd)
static void blender::read_undo_libraries_cleanup_unused_ids (FileData *fd)
static ID * blender::library_id_is_yet_read (FileData *fd, Main *mainvar, BHead *bhead)
static bool blender::read_libblock_undo_restore_linked (FileData *fd, Main *libmain, const ID *id, ID **r_id_old, BHead *bhead)
static void blender::read_libblock_undo_restore_identical (FileData *fd, Main *main, const ID *, ID *id_old, BHead *bhead, const eID_Tag id_tag)
static void blender::read_libblock_undo_restore_at_old_address (FileData *fd, Main *main, ID *id, ID *id_old)
static bool blender::read_libblock_undo_restore (FileData *fd, Main *main, BHead *bhead, const eID_Tag id_tag, ID **r_id_old)
static BHead * blender::read_libblock (FileData *fd, Main *main, BHead *bhead, eID_Tag id_tag, ID_Readfile_Data::Tags id_read_tags, const bool placeholder_set_indirect_extern, ID **r_id)
Read Asset Data
BHead * blender::blo_read_asset_data_block (FileData *fd, BHead *bhead, AssetMetaData **r_asset_data)
Read Global Data
static BHead * blender::read_global (BlendFileData *bfd, FileData *fd, BHead *bhead)
static void blender::link_global (FileData *fd, BlendFileData *bfd)
Versioning
static void blender::do_versions_userdef (FileData *, BlendFileData *bfd)
static void blender::do_versions (FileData *fd, Library *lib, Main *main)
static void blender::do_versions_after_linking (FileData *fd, Main *main)
Read Library Data Block (all)
static int blender::lib_link_cb (LibraryIDLinkCallbackData *cb_data)
static void blender::lib_link_all (FileData *fd, Main *bmain)
static void blender::after_liblink_merged_bmain_process (Main *bmain, BlendFileReadReport *reports)
Read User Preferences
static void blender::direct_link_keymapitem (BlendDataReader *reader, wmKeyMapItem *kmi)
static size_t blender::user_menu_item_struct_size (const eUserMenu_Type type)
static BHead * blender::read_userdef (BlendFileData *bfd, FileData *fd, BHead *bhead)
Read File (Internal)
static int blender::read_undo_remap_noundo_data_cb (LibraryIDLinkCallbackData *cb_data)
static void blender::read_undo_remap_noundo_data (FileData *fd)
static void blender::blo_read_file_checks (Main *bmain)
BlendFileData * blender::blo_read_file_internal (FileData *fd, const char *filepath)
Library Linking (helper functions)
static ID * blender::link_named_part (Main *mainl, FileData *fd, const short idcode, const char *name, const int flag)
static Main * blender::library_link_begin (Main *mainvar, FileData *fd, const char *filepath, const eID_Tag id_tag_extra)
static void blender::split_main_newid (Main *mainptr, Main *main_newid)
static void blender::library_link_end (Main *mainl, FileData **fd, const int flag, ReportList *reports)
void * blender::BLO_library_read_struct (FileData *fd, BHead *bh, const char *blockname)
BLO Blend File Linking API
ID * blender::BLO_library_link_named_part (Main *mainl, BlendHandle **bh, short idcode, const char *name, const LibraryLink_Params *params)
void blender::BLO_library_link_params_init (LibraryLink_Params *params, Main *bmain, int flag, int id_tag_extra)
void blender::BLO_library_link_params_init_with_context (LibraryLink_Params *params, Main *bmain, int flag, int id_tag_extra, Scene *scene, ViewLayer *view_layer, const View3D *v3d)
Main * blender::BLO_library_link_begin (BlendHandle **bh, const char *filepath, const LibraryLink_Params *params)
void blender::BLO_library_link_end (Main *mainl, BlendHandle **bh, const LibraryLink_Params *params, ReportList *reports)
Blend Read Data API

Generally, for every BLO_write_* call there should be a corresponding BLO_read_* call.

Most BLO_read_* functions get a pointer to a pointer as argument. That allows the function to update the pointer to its new value.

When the given pointer points to a memory buffer that was not stored in the file, the pointer is updated to be NULL. When it was pointing to NULL before, it will stay that way.

Examples of matching calls:

writer->write_struct(clmd->sim_parms);
BLO_read_struct(reader, ClothSimSettings, &clmd->sim_parms);
writer->write_struct_list(&action->markers);
BLO_read_struct_list(reader, TimeMarker, &action->markers);
writer->write_int32_array(hmd->totindex, hmd->indexar);
if (!BLO_read_array(reader, &hmd->indexar, hmd->totindex)) {
hmd->totindex = 0;
}
#define BLO_read_struct_list(reader, struct_name, list)
#define BLO_read_struct(reader, struct_name, ptr_p)
bool BLO_read_array(BlendDataReader *reader, T **ptr_p, const SizeT array_size, const int elems=1)

Avoid using the generic BLO_read_raw_address when possible, use the typed functions instead. Only data written with #BlendWriter::write_raw should typically be read with BLO_read_raw_address.

void * blender::blo_read_raw_address_impl (BlendDataReader *reader, const void *old_address)
void * blender::blo_read_struct_impl (BlendDataReader *reader, const void *old_address, size_t expected_size)
void * blender::blo_read_struct_no_us_impl (BlendDataReader *reader, const void *old_address, size_t expected_size)
void * blender::blo_read_struct_nonnull_impl (BlendDataReader *reader, const void *old_address, size_t expected_size)
void * blender::blo_read_struct_no_us_nonnull_impl (BlendDataReader *reader, const void *old_address, size_t expected_size)
bool blender::blo_read_array_impl (BlendDataReader *reader, int64_t array_size, int elems, size_t elem_size, void **ptr_p)
void * blender::BLO_read_struct_by_name_array (BlendDataReader *reader, StringRef struct_name, int64_t items_num, const void *old_address)
int blender::BLO_read_fileversion_get (BlendDataReader *reader)
void blender::BLO_read_struct_list_with_size (BlendDataReader *reader, size_t expected_elem_size, ListBase *list)
void blender::BLO_read_struct_list_with_type_size (BlendDataReader *reader, size_t base_size, ListBase *list, FunctionRef< size_t(const void *data)> type_size_fn)
void * blender::blo_read_struct_with_type_size_impl (BlendDataReader *reader, const void *old_address, size_t base_size, FunctionRef< size_t(const void *data)> type_size_fn)
void blender::BLO_read_string (BlendDataReader *reader, char **ptr_p)
void blender::BLO_read_string (BlendDataReader *reader, char *const *ptr_p)
bool blender::blo_read_pointer_array_impl (BlendDataReader *reader, int64_t array_size, void **ptr_p)
bool blender::BLO_read_data_is_undo (BlendDataReader *reader)
void blender::BLO_read_data_globmap_add (BlendDataReader *reader, void *oldaddr, void *newaddr)
void blender::BLO_read_glob_list (BlendDataReader *reader, ListBase *list)
BlendFileReadReport * blender::BLO_read_data_reports (BlendDataReader *reader)
void blender::BLO_read_data_invalidate (BlendDataReader *reader, const char *message)
void blender::BLO_read_data_set_need_preview_render_restart (BlendDataReader *reader)
Blend Read Lib API

This API does almost the same as the Blend Read Data API. However, now only pointers to ID data blocks are updated.

ID * blender::BLO_read_get_new_id_address (BlendLibReader *reader, ID *self_id, const bool is_linked_only, ID *id) ATTR_NONNULL(2)
ID * blender::BLO_read_get_new_id_address_from_session_uid (BlendLibReader *reader, uint session_uid) ATTR_NONNULL(1)
bool blender::BLO_read_lib_is_undo (BlendLibReader *reader)
Main * blender::BLO_read_lib_get_main (BlendLibReader *reader)
BlendFileReadReport * blender::BLO_read_lib_reports (BlendLibReader *reader)

Variables

static CLG_LogRef blender::LOG = {"blend.readfile"}
static CLG_LogRef blender::LOG_UNDO = {"undo"}

Library Linking (expand pointers)

using blender::BLOExpandDoitCallback
static Main * blender::blo_find_main_for_library_and_idname (FileData *fd, const BHead *bheadlib, const char *lib_filepath, const char *relabase, const BHead *id_bhead, const char *id_name, const bool is_packed_id, const bool is_external_lib)
static void blender::read_id_in_lib (FileData *fd, std::queue< ID * > &ids_to_expand, Main *libmain, Library *parent_lib, BHead *bhead, ID *existing_id, ID_Readfile_Data::Tags id_read_tags)
static void blender::expand_doit_library (void *fdhandle, std::queue< ID * > &ids_to_expand, Main *mainvar, void *old)
static int blender::expand_cb (LibraryIDLinkCallbackData *cb_data)
static void blender::expand_main (void *fdhandle, Main *mainvar, BLOExpandDoitCallback callback)

Macro Definition Documentation

◆ BHEAD_USE_READ_ON_DEMAND

#define BHEAD_USE_READ_ON_DEMAND ( bhead)
Value:
((bhead)->code == BLO_CODE_DATA)

We could change this in the future, for now it's simplest if only data is delayed because ID names are used in lookup tables.

Definition at line 231 of file readfile.cc.

Referenced by blender::blo_filedata_free(), and blender::get_bhead().

◆ BHEADN_FROM_BHEAD

#define BHEADN_FROM_BHEAD ( bh)
Value:
((BHeadN *)POINTER_OFFSET(bh, -int(offsetof(BHeadN, bhead))))
#define POINTER_OFFSET(v, ofs)
#define offsetof(t, d)

Definition at line 225 of file readfile.cc.

Referenced by blender::blo_bhead_next(), blender::blo_bhead_prev(), blender::blo_bhead_read_data(), blender::blo_bhead_read_full(), blender::read_libblock_is_identical(), and blender::read_struct().

◆ DNA_DEPRECATED_ALLOW

#define DNA_DEPRECATED_ALLOW

Definition at line 36 of file readfile.cc.

◆ U

#define U   (*((const UserDef *)&U))

Definition at line 130 of file readfile.cc.

◆ USE_BHEAD_READ_ON_DEMAND

#define USE_BHEAD_READ_ON_DEMAND

READ

  • Existing Library (#Main) push or free
  • allocate new #Main
  • load file
  • read #SDNA
  • for each LibBlock
    • read LibBlock
    • if a Library
      • make a new #Main
      • attach ID's to it
    • else
      • read associated 'direct data'
      • link direct data (internal and to LibBlock)
  • read #FileGlobal
  • read #USER data, only when indicated (file is ~/.config/blender/X.X/config/userpref.blend)
  • free file
  • per Library (per #Main)
    • read file
    • read #SDNA
    • find LibBlocks and attach #ID's to #Main
      • if external LibBlock
        • search all #Main's
          • or it's already read,
          • or not read yet
          • or make new #Main
    • per LibBlock
      • read recursive
      • read associated direct data
      • link direct data (internal and to LibBlock)
    • free file
  • per Library with unread LibBlocks
    • read file
    • read #SDNA
    • per LibBlock
      • read recursive
      • read associated direct data
      • link direct data (internal and to LibBlock)
    • free file
  • join all #Main's
  • link all LibBlocks and indirect pointers to libblocks
  • initialize #FileGlobal and copy pointers to #Global
Note
Still a weak point is the new-address function, that doesn't solve reading from multiple files at the same time. (added remark: oh, i thought that was solved? will look at that... (ton)). Delay reading blocks we might not use (especially applies to library linking). which keeps large arrays in memory from data-blocks we may not even use.
This is disabled when using compression, while ZLIB supports seek it's unusably slow, see: #61880.

Definition at line 189 of file readfile.cc.