Blender  V3.3
Classes | Macros | Typedefs | Functions | Variables
readfile.c File Reference
#include <ctype.h>
#include <fcntl.h>
#include <limits.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <time.h>
#include "BLI_utildefines.h"
#include <unistd.h>
#include "CLG_log.h"
#include "DNA_anim_types.h"
#include "DNA_asset_types.h"
#include "DNA_cachefile_types.h"
#include "DNA_collection_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_sdna_types.h"
#include "DNA_sound_types.h"
#include "DNA_vfont_types.h"
#include "DNA_volume_types.h"
#include "DNA_workspace_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_endian_defines.h"
#include "BLI_endian_switch.h"
#include "BLI_ghash.h"
#include "BLI_linklist.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
#include "BLI_mempool.h"
#include "BLI_threads.h"
#include "PIL_time.h"
#include "BLT_translation.h"
#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_asset.h"
#include "BKE_blender_version.h"
#include "BKE_collection.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
#include "BKE_idtype.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
#include "BKE_lib_override.h"
#include "BKE_lib_query.h"
#include "BKE_main.h"
#include "BKE_main_idmap.h"
#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_packedFile.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_undo_system.h"
#include "BKE_workspace.h"
#include "DRW_engine.h"
#include "DEG_depsgraph.h"
#include "BLO_blend_defs.h"
#include "BLO_blend_validate.h"
#include "BLO_read_write.h"
#include "BLO_readfile.h"
#include "BLO_undofile.h"
#include "SEQ_clipboard.h"
#include "SEQ_iterator.h"
#include "SEQ_modifier.h"
#include "SEQ_sequencer.h"
#include "SEQ_utils.h"
#include "readfile.h"
#include <errno.h>

Go to the source code of this file.

Classes

struct  BHeadN
 
struct  OldNew
 
struct  OldNewMap
 
struct  BlendDataReader
 
struct  BlendLibReader
 
struct  BlendExpander
 
struct  BLOCacheStorage
 
struct  BLOCacheStorageValue
 
struct  BHeadSort
 

Macros

#define DNA_DEPRECATED_ALLOW
 
#define U   (*((const UserDef *)&U))
 
#define USE_BHEAD_READ_ON_DEMAND
 
#define USE_GHASH_BHEAD
 
#define USE_GHASH_RESTORE_POINTER
 
#define BHEADN_FROM_BHEAD(bh)   ((BHeadN *)POINTER_OFFSET(bh, -(int)offsetof(BHeadN, bhead)))
 
#define BHEAD_USE_READ_ON_DEMAND(bhead)   ((bhead)->code == DATA)
 

Typedefs

typedef struct BHeadN BHeadN
 

Functions

void BLO_reportf_wrap (BlendFileReadReport *reports, eReportType type, const char *format,...)
 
static const char * library_parent_filepath (Library *lib)
 
Library Reading
static void read_libraries (FileData *basefd, ListBase *mainlist)
 
static int has_linked_ids_to_read (Main *mainvar)
 
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 read_library_clear_weak_links (FileData *basefd, ListBase *mainlist, Main *mainvar)
 
static FileDataread_library_file_data (FileData *basefd, ListBase *mainlist, Main *mainl, Main *mainptr)
 
voidBLO_read_get_new_data_address (BlendDataReader *reader, const void *old_address)
 
voidBLO_read_get_new_data_address_no_us (BlendDataReader *reader, const void *old_address)
 
voidBLO_read_get_new_packed_address (BlendDataReader *reader, const void *old_address)
 
IDBLO_read_get_new_id_address (BlendLibReader *reader, Library *lib, ID *id)
 
bool BLO_read_requires_endian_switch (BlendDataReader *reader)
 
void BLO_read_list_cb (BlendDataReader *reader, ListBase *list, BlendReadListFn callback)
 
void BLO_read_list (BlendDataReader *reader, struct ListBase *list)
 
void BLO_read_int32_array (BlendDataReader *reader, int array_size, int32_t **ptr_p)
 
void BLO_read_uint32_array (BlendDataReader *reader, int array_size, uint32_t **ptr_p)
 
void BLO_read_float_array (BlendDataReader *reader, int array_size, float **ptr_p)
 
void BLO_read_float3_array (BlendDataReader *reader, int array_size, float **ptr_p)
 
void BLO_read_double_array (BlendDataReader *reader, int array_size, double **ptr_p)
 
static void convert_pointer_array_64_to_32 (BlendDataReader *reader, uint array_size, const uint64_t *src, uint32_t *dst)
 
static void convert_pointer_array_32_to_64 (BlendDataReader *UNUSED(reader), uint array_size, const uint32_t *src, uint64_t *dst)
 
void BLO_read_pointer_array (BlendDataReader *reader, void **ptr_p)
 
bool BLO_read_data_is_undo (BlendDataReader *reader)
 
void BLO_read_data_globmap_add (BlendDataReader *reader, void *oldaddr, void *newaddr)
 
void BLO_read_glob_list (BlendDataReader *reader, ListBase *list)
 
BlendFileReadReportBLO_read_data_reports (BlendDataReader *reader)
 
bool BLO_read_lib_is_undo (BlendLibReader *reader)
 
MainBLO_read_lib_get_main (BlendLibReader *reader)
 
BlendFileReadReportBLO_read_lib_reports (BlendLibReader *reader)
 
void BLO_expand_id (BlendExpander *expander, ID *id)
 
DNA Struct Loading
static voidread_struct (FileData *fd, BHead *bh, const char *blockname)
 
static void switch_endian_structs (const struct SDNA *filesdna, BHead *bhead)
 
static const voidpeek_struct_undo (FileData *fd, BHead *bhead)
 
static void link_glob_list (FileData *fd, ListBase *lb)
 
Library Linking

Also used for append.

static BHeadfind_bhead_from_code_name (FileData *fd, const short idcode, const char *name)
 
static BHeadfind_bhead_from_idname (FileData *fd, const char *idname)
 
static int verg_bheadsort (const void *v1, const void *v2)
 
static void sort_bhead_old_map (FileData *fd)
 
static BHeadfind_previous_lib (FileData *fd, BHead *bhead)
 
static BHeadfind_bhead (FileData *fd, void *old)
 
static IDis_yet_read (FileData *fd, Main *mainvar, BHead *bhead)
 
Helper Functions
static void add_main_to_main (Main *mainvar, Main *from)
 
void blo_join_main (ListBase *mainlist)
 
static void split_libdata (ListBase *lb_src, Main **lib_main_array, const uint lib_main_array_len)
 
void blo_split_main (ListBase *mainlist, Main *main)
 
static void file_global_minversion_hotfix (FileGlobal *fg)
 
static void read_file_version (FileData *fd, Main *main)
 
static bool blo_bhead_is_id (const BHead *bhead)
 
static bool blo_bhead_is_id_valid_type (const BHead *bhead)
 
static void read_file_bhead_idname_map_create (FileData *fd)
 
static Mainblo_find_main (FileData *fd, const char *filepath, const char *relabase)
 
void blo_readfile_invalidate (FileData *fd, Main *bmain, const char *message)
 
File Data API
static FileDatafiledata_new (BlendFileReadReport *reports)
 
static bool is_minversion_older_than_blender (FileData *fd, ReportList *reports)
 
static FileDatablo_decode_and_check (FileData *fd, ReportList *reports)
 
static FileDatablo_filedata_from_file_descriptor (const char *filepath, BlendFileReadReport *reports, int filedes)
 
static FileDatablo_filedata_from_file_open (const char *filepath, BlendFileReadReport *reports)
 
FileDatablo_filedata_from_file (const char *filepath, BlendFileReadReport *reports)
 
static FileDatablo_filedata_from_file_minimal (const char *filepath)
 
FileDatablo_filedata_from_memory (const void *mem, int memsize, BlendFileReadReport *reports)
 
FileDatablo_filedata_from_memfile (MemFile *memfile, const struct BlendFileReadParams *params, BlendFileReadReport *reports)
 
void blo_filedata_free (FileData *fd)
 
Public Utilities
bool BLO_has_bfile_extension (const char *str)
 
bool BLO_library_path_explode (const char *path, char *r_dir, char **r_group, char **r_name)
 
BlendThumbnailBLO_thumbnail_from_file (const char *filepath)
 
Read ID
static void lib_link_id (BlendLibReader *reader, ID *id)
 
static void lib_link_id_embedded_id (BlendLibReader *reader, ID *id)
 
static void direct_link_id_override_property_operation_cb (BlendDataReader *reader, void *data)
 
static void direct_link_id_override_property_cb (BlendDataReader *reader, void *data)
 
static void direct_link_id_common (BlendDataReader *reader, Library *current_library, ID *id, ID *id_old, const int tag)
 
static void direct_link_id_embedded_id (BlendDataReader *reader, Library *current_library, ID *id, ID *id_old)
 
static int direct_link_id_restore_recalc_exceptions (const ID *id_current)
 
static int direct_link_id_restore_recalc (const FileData *fd, const ID *id_target, const ID *id_current, const bool is_identical)
 
Read ID: Shape Keys
void blo_do_versions_key_uidgen (Key *key)
 
Read ID: Scene
static void lib_link_scenes_check_set (Main *bmain)
 
Read ID: Library
static void direct_link_library (FileData *fd, Library *lib, Main *main)
 
static void lib_link_library (BlendLibReader *UNUSED(reader), Library *UNUSED(lib))
 
static void fix_relpaths_library (const char *basepath, Main *main)
 
Read Library Data Block
static IDcreate_placeholder (Main *mainvar, const short idcode, const char *idname, const int tag)
 
static void placeholders_ensure_valid (Main *bmain)
 
static const char * dataname (short id_code)
 
static bool direct_link_id (FileData *fd, Main *main, const int tag, ID *id, ID *id_old)
 
static BHeadread_data_into_datamap (FileData *fd, BHead *bhead, const char *allocname)
 
static bool read_libblock_is_identical (FileData *fd, BHead *bhead)
 
static bool read_libblock_undo_restore_library (FileData *fd, Main *main, const ID *id)
 
static bool read_libblock_undo_restore_linked (FileData *fd, Main *main, const ID *id, BHead *bhead)
 
static void read_libblock_undo_restore_identical (FileData *fd, Main *main, const ID *UNUSED(id), ID *id_old, const int tag)
 
static void read_libblock_undo_restore_at_old_address (FileData *fd, Main *main, ID *id, ID *id_old)
 
static bool read_libblock_undo_restore (FileData *fd, Main *main, BHead *bhead, const int tag, ID **r_id_old)
 
static BHeadread_libblock (FileData *fd, Main *main, BHead *bhead, const int tag, const bool placeholder_set_indirect_extern, ID **r_id)
 
Read Asset Data
BHeadblo_read_asset_data_block (FileData *fd, BHead *bhead, AssetMetaData **r_asset_data)
 
Read Global Data
static BHeadread_global (BlendFileData *bfd, FileData *fd, BHead *bhead)
 
static void link_global (FileData *fd, BlendFileData *bfd)
 
Versioning
static void do_versions_userdef (FileData *UNUSED(fd), BlendFileData *bfd)
 
static void do_versions (FileData *fd, Library *lib, Main *main)
 
static void do_versions_after_linking (FileData *fd, Main *main)
 
Read Library Data Block (all)
static void lib_link_all (FileData *fd, Main *bmain)
 
static void after_liblink_merged_bmain_process (Main *bmain)
 
Read User Preferences
static void direct_link_keymapitem (BlendDataReader *reader, wmKeyMapItem *kmi)
 
static BHeadread_userdef (BlendFileData *bfd, FileData *fd, BHead *bhead)
 
Read File (Internal)
BlendFileDatablo_read_file_internal (FileData *fd, const char *filepath)
 
Library Linking (helper functions)
static IDlink_named_part (Main *mainl, FileData *fd, const short idcode, const char *name, const int flag)
 
IDBLO_library_link_named_part (Main *mainl, BlendHandle **bh, const short idcode, const char *name, const struct LibraryLink_Params *params)
 
static Mainlibrary_link_begin (Main *mainvar, FileData **fd, const char *filepath, const int id_tag_extra)
 
void BLO_library_link_params_init (struct LibraryLink_Params *params, struct Main *bmain, const int flag, const int 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, struct Scene *scene, struct ViewLayer *view_layer, const struct View3D *v3d)
 
MainBLO_library_link_begin (BlendHandle **bh, const char *filepath, const struct LibraryLink_Params *params)
 
static void split_main_newid (Main *mainptr, Main *main_newid)
 
static void library_link_end (Main *mainl, FileData **fd, const int flag)
 
void BLO_library_link_end (Main *mainl, BlendHandle **bh, const struct LibraryLink_Params *params)
 
voidBLO_library_read_struct (FileData *fd, BHead *bh, const char *blockname)
 

Variables

static CLG_LogRef LOG = {"blo.readfile"}
 
static CLG_LogRef LOG_UNDO = {"blo.readfile.undo"}
 

OldNewMap API

#define ENTRIES_CAPACITY(onm)   (1ll << (onm)->capacity_exp)
 
#define MAP_CAPACITY(onm)   (1ll << ((onm)->capacity_exp + 1))
 
#define SLOT_MASK(onm)   (MAP_CAPACITY(onm) - 1)
 
#define DEFAULT_SIZE_EXP   6
 
#define PERTURB_SHIFT   5
 
#define ITER_SLOTS(onm, KEY, SLOT_NAME, INDEX_NAME)
 
typedef struct OldNew OldNew
 
typedef struct OldNewMap OldNewMap
 
static void oldnewmap_insert_index_in_map (OldNewMap *onm, const void *ptr, int index)
 
static void oldnewmap_insert_or_replace (OldNewMap *onm, OldNew entry)
 
static OldNewoldnewmap_lookup_entry (const OldNewMap *onm, const void *addr)
 
static void oldnewmap_clear_map (OldNewMap *onm)
 
static void oldnewmap_increase_size (OldNewMap *onm)
 
static void oldnewmap_init_data (OldNewMap *onm, const int capacity_exp)
 
static OldNewMapoldnewmap_new (void)
 
static void oldnewmap_insert (OldNewMap *onm, const void *oldaddr, void *newaddr, int nr)
 
static void oldnewmap_lib_insert (FileData *fd, const void *oldaddr, ID *newaddr, int nr)
 
void blo_do_versions_oldnewmap_insert (OldNewMap *onm, const void *oldaddr, void *newaddr, int nr)
 
static voidoldnewmap_lookup_and_inc (OldNewMap *onm, const void *addr, bool increase_users)
 
static voidoldnewmap_liblookup (OldNewMap *onm, const void *addr, const void *lib)
 
static void oldnewmap_clear (OldNewMap *onm)
 
static void oldnewmap_free (OldNewMap *onm)
 

Read ID: Screen

enum  ePointerUserMode { USER_IGNORE = 0 , USER_REAL = 1 }
 
typedef enum ePointerUserMode ePointerUserMode
 
static void restore_pointer_user (ID *id, ID *newid, ePointerUserMode user)
 
static voidrestore_pointer_by_name (struct IDNameLib_Map *id_map, ID *id, ePointerUserMode user)
 
static void lib_link_seq_clipboard_pt_restore (ID *id, struct IDNameLib_Map *id_map)
 
static bool lib_link_seq_clipboard_cb (Sequence *seq, void *arg_pt)
 
static void lib_link_clipboard_restore (struct IDNameLib_Map *id_map)
 
static int lib_link_main_data_restore_cb (LibraryIDLinkCallbackData *cb_data)
 
static void lib_link_main_data_restore (struct IDNameLib_Map *id_map, Main *newmain)
 
static void lib_link_wm_xr_data_restore (struct IDNameLib_Map *id_map, wmXrData *xr_data)
 
static void lib_link_window_scene_data_restore (wmWindow *win, Scene *scene, ViewLayer *view_layer)
 
static void lib_link_workspace_layout_restore (struct IDNameLib_Map *id_map, Main *newmain, WorkSpaceLayout *layout)
 
void blo_lib_link_restore (Main *oldmain, Main *newmain, wmWindowManager *curwm, Scene *curscene, ViewLayer *cur_view_layer)
 

File Parsing

typedef struct BlendDataReader BlendDataReader
 
typedef struct BlendLibReader BlendLibReader
 
typedef struct BlendExpander BlendExpander
 
static void switch_endian_bh4 (BHead4 *bhead)
 
static void switch_endian_bh8 (BHead8 *bhead)
 
static void bh4_from_bh8 (BHead *bhead, BHead8 *bhead8, bool do_endian_swap)
 
static void bh8_from_bh4 (BHead *bhead, BHead4 *bhead4)
 
static BHeadNget_bhead (FileData *fd)
 
BHeadblo_bhead_first (FileData *fd)
 
BHeadblo_bhead_prev (FileData *UNUSED(fd), BHead *thisblock)
 
BHeadblo_bhead_next (FileData *fd, BHead *thisblock)
 
static bool blo_bhead_read_data (FileData *fd, BHead *thisblock, void *buf)
 
static BHeadblo_bhead_read_full (FileData *fd, BHead *thisblock)
 
const char * blo_bhead_id_name (const FileData *fd, const BHead *bhead)
 
AssetMetaDatablo_bhead_id_asset_data_address (const FileData *fd, const BHead *bhead)
 
static void decode_blender_header (FileData *fd)
 
static bool read_file_dna (FileData *fd, const char **r_error_message)
 
static int * read_file_thumbnail (FileData *fd)
 

Old/New Pointer Map

typedef struct BLOCacheStorage BLOCacheStorage
 
typedef struct BLOCacheStorageValue BLOCacheStorageValue
 
static voidnewdataadr (FileData *fd, const void *adr)
 
static voidnewdataadr_no_us (FileData *fd, const void *adr)
 
voidblo_read_get_new_globaldata_address (FileData *fd, const void *adr)
 
static voidnewpackedadr (FileData *fd, const void *adr)
 
static voidnewlibadr (FileData *fd, const void *lib, const void *adr)
 
voidblo_do_versions_newlibadr (FileData *fd, const void *lib, const void *adr)
 
static void change_link_placeholder_to_real_ID_pointer_fd (FileData *fd, const void *old, void *new)
 
static void change_link_placeholder_to_real_ID_pointer (ListBase *mainlist, FileData *basefd, void *old, void *new)
 
static void insert_packedmap (FileData *fd, PackedFile *pf)
 
void blo_make_packed_pointer_map (FileData *fd, Main *oldmain)
 
void blo_end_packed_pointer_map (FileData *fd, Main *oldmain)
 
void blo_add_library_pointer_map (ListBase *old_mainlist, FileData *fd)
 
void blo_make_old_idmap_from_main (FileData *fd, Main *bmain)
 
static void blo_cache_storage_entry_register (ID *id, const IDCacheKey *key, void **cache_p, uint UNUSED(flags), void *cache_storage_v)
 
static void blo_cache_storage_entry_restore_in_new (ID *UNUSED(id), const IDCacheKey *key, void **cache_p, uint flags, void *cache_storage_v)
 
static void blo_cache_storage_entry_clear_in_old (ID *UNUSED(id), const IDCacheKey *key, void **cache_p, uint UNUSED(flags), void *cache_storage_v)
 
void blo_cache_storage_init (FileData *fd, Main *bmain)
 
void blo_cache_storage_old_bmain_clear (FileData *fd, Main *bmain_old)
 
void blo_cache_storage_end (FileData *fd)
 

Library Linking (expand pointers)

static BLOExpandDoitCallback expand_doit
 
static void expand_doit_library (void *fdhandle, Main *mainvar, void *old)
 
static void expand_id (BlendExpander *expander, ID *id)
 
static void expand_id_embedded_id (BlendExpander *expander, ID *id)
 
void BLO_main_expander (BLOExpandDoitCallback expand_doit_func)
 
void BLO_expand_main (void *fdhandle, Main *mainvar)
 

Macro Definition Documentation

◆ BHEAD_USE_READ_ON_DEMAND

#define BHEAD_USE_READ_ON_DEMAND (   bhead)    ((bhead)->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 202 of file readfile.c.

◆ BHEADN_FROM_BHEAD

#define BHEADN_FROM_BHEAD (   bh)    ((BHeadN *)POINTER_OFFSET(bh, -(int)offsetof(BHeadN, bhead)))

Definition at line 196 of file readfile.c.

◆ DEFAULT_SIZE_EXP

#define DEFAULT_SIZE_EXP   6

Definition at line 253 of file readfile.c.

◆ DNA_DEPRECATED_ALLOW

#define DNA_DEPRECATED_ALLOW

Definition at line 28 of file readfile.c.

◆ ENTRIES_CAPACITY

#define ENTRIES_CAPACITY (   onm)    (1ll << (onm)->capacity_exp)

Definition at line 250 of file readfile.c.

◆ ITER_SLOTS

#define ITER_SLOTS (   onm,
  KEY,
  SLOT_NAME,
  INDEX_NAME 
)
Value:
uint32_t mask = SLOT_MASK(onm); \
uint perturb = hash; \
int SLOT_NAME = mask & hash; \
int INDEX_NAME = onm->map[SLOT_NAME]; \
for (;; SLOT_NAME = mask & ((5 * SLOT_NAME) + 1 + perturb), \
perturb >>= PERTURB_SHIFT, \
INDEX_NAME = onm->map[SLOT_NAME])
unsigned int BLI_ghashutil_ptrhash(const void *key)
#define KEY(a)
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
#define hash
Definition: noise.c:153
#define SLOT_MASK(onm)
Definition: readfile.c:252
#define PERTURB_SHIFT
Definition: readfile.c:254
unsigned int uint32_t
Definition: stdint.h:80

Definition at line 257 of file readfile.c.

◆ MAP_CAPACITY

#define MAP_CAPACITY (   onm)    (1ll << ((onm)->capacity_exp + 1))

Definition at line 251 of file readfile.c.

◆ PERTURB_SHIFT

#define PERTURB_SHIFT   5

Definition at line 254 of file readfile.c.

◆ SLOT_MASK

#define SLOT_MASK (   onm)    (MAP_CAPACITY(onm) - 1)

Definition at line 252 of file readfile.c.

◆ U

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

Definition at line 108 of file readfile.c.

◆ 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.XX/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: T61880.

Definition at line 167 of file readfile.c.

◆ USE_GHASH_BHEAD

#define USE_GHASH_BHEAD

Use GHash for BHead name-based lookups (speeds up linking).

Definition at line 170 of file readfile.c.

◆ USE_GHASH_RESTORE_POINTER

#define USE_GHASH_RESTORE_POINTER

Use GHash for restoring pointers by name.

Definition at line 173 of file readfile.c.

Typedef Documentation

◆ BHeadN

typedef struct BHeadN BHeadN

◆ BlendDataReader

◆ BlendExpander

typedef struct BlendExpander BlendExpander

◆ BlendLibReader

◆ BLOCacheStorage

◆ BLOCacheStorageValue

◆ ePointerUserMode

◆ OldNew

typedef struct OldNew OldNew

◆ OldNewMap

typedef struct OldNewMap OldNewMap

Enumeration Type Documentation

◆ ePointerUserMode

Enumerator
USER_IGNORE 
USER_REAL 

Definition at line 2399 of file readfile.c.

Function Documentation

◆ add_main_to_main()

static void add_main_to_main ( Main mainvar,
Main from 
)
static

◆ after_liblink_merged_bmain_process()

static void after_liblink_merged_bmain_process ( Main bmain)
static

Checks to perform after lib_link_all. Those operations cannot perform properly in a split bmain case, since some data from other bmain's (aka libraries) may not have been processed yet.

Definition at line 3837 of file readfile.c.

References BKE_main_collections_parent_relations_rebuild(), BLI_assert, BLO_main_validate_embedded_liboverrides(), BLO_main_validate_shapekeys(), lib_link_scenes_check_set(), Main::next, NULL, and Main::prev.

Referenced by blo_read_file_internal(), and library_link_end().

◆ bh4_from_bh8()

static void bh4_from_bh8 ( BHead bhead,
BHead8 bhead8,
bool  do_endian_swap 
)
static

◆ bh8_from_bh4()

static void bh8_from_bh4 ( BHead bhead,
BHead4 bhead4 
)
static

◆ blo_add_library_pointer_map()

void blo_add_library_pointer_map ( ListBase old_mainlist,
FileData fd 
)

Undo file support: add all library pointers in lookup.

Definition at line 1759 of file readfile.c.

References GS, id, INDEX_ID_MAX, LISTBASE_FOREACH, ID::name, FileData::old_mainlist, oldnewmap_lib_insert(), ptr, and set_listbasepointers().

Referenced by BLO_read_from_memfile().

◆ blo_bhead_first()

BHead* blo_bhead_first ( FileData fd)

◆ blo_bhead_id_asset_data_address()

AssetMetaData* blo_bhead_id_asset_data_address ( const FileData fd,
const BHead bhead 
)

Warning! Caller's responsibility to ensure given bhead is an ID one!

Definition at line 1036 of file readfile.c.

References BLI_assert, blo_bhead_is_id_valid_type(), FileData::id_asset_data_offset, NULL, and POINTER_OFFSET.

Referenced by BLO_blendhandle_get_datablock_info(), and BLO_blendhandle_get_datablock_names().

◆ blo_bhead_id_name()

const char* blo_bhead_id_name ( const FileData fd,
const BHead bhead 
)

◆ blo_bhead_is_id()

static bool blo_bhead_is_id ( const BHead bhead)
static

Definition at line 583 of file readfile.c.

References BHead::code.

Referenced by blo_bhead_is_id_valid_type().

◆ blo_bhead_is_id_valid_type()

static bool blo_bhead_is_id_valid_type ( const BHead bhead)
static

◆ blo_bhead_next()

BHead* blo_bhead_next ( FileData fd,
BHead thisblock 
)

◆ blo_bhead_prev()

BHead* blo_bhead_prev ( FileData UNUSEDfd,
BHead thisblock 
)

◆ blo_bhead_read_data()

static bool blo_bhead_read_data ( FileData fd,
BHead thisblock,
void buf 
)
static

◆ blo_bhead_read_full()

static BHead* blo_bhead_read_full ( FileData fd,
BHead thisblock 
)
static

◆ blo_cache_storage_end()

void blo_cache_storage_end ( FileData fd)

◆ blo_cache_storage_entry_clear_in_old()

static void blo_cache_storage_entry_clear_in_old ( ID UNUSEDid,
const IDCacheKey key,
void **  cache_p,
uint   UNUSEDflags,
void cache_storage_v 
)
static

Clear as needed a cache data entry from old ID, when reading some undo memfile.

Definition at line 1838 of file readfile.c.

References BLI_assert, BLI_ghash_lookup(), BLOCacheStorage::cache_map, BLOCacheStorageValue::cache_v, BLOCacheStorageValue::new_usage_count, and NULL.

Referenced by blo_cache_storage_old_bmain_clear().

◆ blo_cache_storage_entry_register()

static void blo_cache_storage_entry_register ( ID id,
const IDCacheKey key,
void **  cache_p,
uint   UNUSEDflags,
void cache_storage_v 
)
static

◆ blo_cache_storage_entry_restore_in_new()

static void blo_cache_storage_entry_restore_in_new ( ID UNUSEDid,
const IDCacheKey key,
void **  cache_p,
uint  flags,
void cache_storage_v 
)
static

Restore a cache data entry from old ID into new one, when reading some undo memfile.

Definition at line 1813 of file readfile.c.

References BLI_ghash_lookup(), BLOCacheStorage::cache_map, BLOCacheStorageValue::cache_v, IDTYPE_CACHE_CB_FLAGS_PERSISTENT, BLOCacheStorageValue::new_usage_count, and NULL.

Referenced by direct_link_id().

◆ blo_cache_storage_init()

void blo_cache_storage_init ( FileData fd,
Main bmain 
)

◆ blo_cache_storage_old_bmain_clear()

void blo_cache_storage_old_bmain_clear ( FileData fd,
Main bmain_old 
)

◆ blo_decode_and_check()

static FileData* blo_decode_and_check ( FileData fd,
ReportList reports 
)
static

◆ blo_do_versions_key_uidgen()

void blo_do_versions_key_uidgen ( Key key)

Definition at line 2323 of file readfile.c.

References Key::block, LISTBASE_FOREACH, and Key::uidgen.

Referenced by blo_do_versions_260().

◆ blo_do_versions_newlibadr()

void* blo_do_versions_newlibadr ( struct FileData fd,
const void lib,
const void adr 
)

Only library data.

Definition at line 1632 of file readfile.c.

References lib, and newlibadr().

Referenced by blo_do_versions_250(), blo_do_versions_260(), blo_do_versions_pre250(), and ntree_version_245().

◆ blo_do_versions_oldnewmap_insert()

void blo_do_versions_oldnewmap_insert ( OldNewMap onm,
const void oldaddr,
void newaddr,
int  nr 
)

Definition at line 368 of file readfile.c.

References oldnewmap_insert().

Referenced by blo_do_versions_pre250().

◆ blo_end_packed_pointer_map()

void blo_end_packed_pointer_map ( FileData fd,
struct Main oldmain 
)

Set old main packed data to zero if it has been restored this works because freeing old main only happens after this call.

Definition at line 1723 of file readfile.c.

References OldNewMap::entries, Main::fonts, Main::images, lib, Main::libraries, LISTBASE_FOREACH, OldNewMap::nentries, OldNew::newp, newpackedadr(), OldNew::nr, NULL, FileData::packedmap, Main::sounds, and Main::volumes.

◆ BLO_expand_id()

void BLO_expand_id ( BlendExpander expander,
ID id 
)

Definition at line 5323 of file readfile.c.

References expand_doit, BlendExpander::fd, and BlendExpander::main.

◆ BLO_expand_main()

void BLO_expand_main ( void fdhandle,
struct Main mainvar 
)

Loop over all ID data in Main to mark relations. Set (id->tag & LIB_TAG_NEED_EXPAND) to mark expanding. Flags get cleared after expanding.

Parameters
fdhandleusually filedata, or own handle.
mainvarthe Main database to expand.

Definition at line 4477 of file readfile.c.

References Freestyle::a, BKE_idtype_get_info_from_id(), IDTypeInfo::blend_read_expand, expand_id(), ListBase::first, id, INDEX_ID_MAX, LIB_TAG_NEED_EXPAND, NULL, set_listbasepointers(), and ID::tag.

Referenced by BKE_blendfile_write_partial(), library_link_end(), and read_libraries().

◆ blo_filedata_free()

void blo_filedata_free ( FileData fd)

◆ blo_filedata_from_file()

FileData* blo_filedata_from_file ( const char *  filepath,
struct BlendFileReadReport reports 
)

On each new library added, it now checks for the current FileData and expands relativeness

cannot be called with relative paths anymore!

Definition at line 1357 of file readfile.c.

References BLI_strncpy(), blo_decode_and_check(), blo_filedata_from_file_open(), NULL, FileData::relabase, and BlendFileReadReport::reports.

Referenced by BLO_blendhandle_from_file(), BLO_read_from_file(), and read_library_file_data().

◆ blo_filedata_from_file_descriptor()

static FileData* blo_filedata_from_file_descriptor ( const char *  filepath,
BlendFileReadReport reports,
int  filedes 
)
static

◆ blo_filedata_from_file_minimal()

static FileData* blo_filedata_from_file_minimal ( const char *  filepath)
static

Same as blo_filedata_from_file(), but does not reads DNA data, only header. Use it for light access (e.g. thumbnail reading).

Definition at line 1373 of file readfile.c.

References blo_filedata_free(), blo_filedata_from_file_open(), decode_blender_header(), FD_FLAGS_FILE_OK, FileData::flags, and NULL.

Referenced by BLO_thumbnail_from_file().

◆ blo_filedata_from_file_open()

static FileData* blo_filedata_from_file_open ( const char *  filepath,
BlendFileReadReport reports 
)
static

◆ blo_filedata_from_memfile()

FileData* blo_filedata_from_memfile ( MemFile memfile,
const struct BlendFileReadParams params,
BlendFileReadReport reports 
)

◆ blo_filedata_from_memory()

FileData* blo_filedata_from_memory ( const void mem,
int  memsize,
BlendFileReadReport reports 
)

◆ blo_find_main()

static Main* blo_find_main ( FileData fd,
const char *  filepath,
const char *  relabase 
)
static

◆ BLO_has_bfile_extension()

bool BLO_has_bfile_extension ( const char *  str)

Check whether given path ends with a blend file compatible extension (.blend, .ble or .blend.gz).

Parameters
strThe path to check.
Returns
true is this path ends with a blender file extension.

Definition at line 1497 of file readfile.c.

References BLI_path_extension_check_array(), NULL, and str.

Referenced by arg_handle_load_file(), blend_save_check(), BLO_library_path_explode(), ED_path_extension_type(), file_path_to_ui_path(), filelist_readjob_list_dir(), recent_files_menu_draw(), uiTemplateRecentFiles(), WM_lib_reload(), and wm_lib_relocate_exec_do().

◆ blo_join_main()

void blo_join_main ( ListBase mainlist)

◆ blo_lib_link_restore()

void blo_lib_link_restore ( struct Main oldmain,
struct Main newmain,
struct wmWindowManager curwm,
struct Scene curscene,
struct ViewLayer cur_view_layer 
)

◆ BLO_library_link_begin()

Main* BLO_library_link_begin ( BlendHandle **  bh,
const char *  filepath,
const struct LibraryLink_Params params 
)

Initialize the BlendHandle for linking library data.

Parameters
bhA blender file handle as returned by BLO_blendhandle_from_file or BLO_blendhandle_from_memory.
filepathUsed for relative linking, copied to the lib->filepath.
paramsSettings for linking that don't change from beginning to end of linking.
Returns
the library Main, to be passed to BLO_library_link_named_part as mainl.

Definition at line 4650 of file readfile.c.

References library_link_begin(), and params.

Referenced by BKE_blendfile_link(), and BLO_library_temp_load_id().

◆ BLO_library_link_end()

void BLO_library_link_end ( struct Main mainl,
BlendHandle **  bh,
const struct LibraryLink_Params params 
)

Finalize linking from a given .blend file (library). Optionally instance the indirect object/collection in the scene when the flags are set.

Note
Do not use bh after calling this function, it may frees it.
Parameters
mainlThe main database to link from (not the active one).
bhThe blender file handle (WARNING! may be freed by this function!).
paramsSettings for linking that don't change from beginning to end of linking.

Definition at line 4787 of file readfile.c.

References Main::is_read_invalid, library_link_end(), and params.

Referenced by BKE_blendfile_link(), and BLO_library_temp_free().

◆ BLO_library_link_named_part()

ID* BLO_library_link_named_part ( struct Main mainl,
BlendHandle **  bh,
short  idcode,
const char *  name,
const struct LibraryLink_Params params 
)

Link a named data-block from an external blend file.

Parameters
mainlThe main database to link from (not the active one).
bhThe blender file handle.
idcodeThe kind of data-block to link.
nameThe name of the data-block (without the 2 char ID prefix).
Returns
the linked ID when found.

Definition at line 4569 of file readfile.c.

References Main::is_read_invalid, link_named_part(), NULL, and params.

Referenced by BKE_blendfile_link(), and BLO_library_temp_load_id().

◆ BLO_library_link_params_init()

void BLO_library_link_params_init ( struct LibraryLink_Params params,
struct Main bmain,
const int  flag,
const int  id_tag_extra 
)

◆ BLO_library_link_params_init_with_context()

void BLO_library_link_params_init_with_context ( struct LibraryLink_Params params,
struct Main bmain,
const int  flag,
const int  id_tag_extra,
struct Scene scene,
struct ViewLayer view_layer,
const struct View3D v3d 
)

◆ BLO_library_path_explode()

bool BLO_library_path_explode ( const char *  path,
char *  r_dir,
char **  r_group,
char **  r_name 
)

Try to explode given path into its 'library components' (i.e. a .blend file, id type/group, and data-block itself).

Parameters
paththe full path to explode.
r_dirthe string that'll contain path up to blend file itself ('library' path). WARNING! Must be FILE_MAX_LIBEXTRA long (it also stores group and name strings)!
r_groupthe string that'll contain 'group' part of the path, if any. May be NULL.
r_namethe string that'll contain data's name part of the path, if any. May be NULL.
Returns
true if path contains a blend file.

Definition at line 1503 of file readfile.c.

References BLI_assert, BLI_is_dir(), BLI_is_file(), BLI_path_slash_rfind(), BLO_EMBEDDED_STARTUP_BLEND, BLO_GROUP_MAX, BLO_has_bfile_extension(), Freestyle::c, MAX_ID_NAME, NULL, and STREQ.

Referenced by ED_asset_handle_get_full_library_path(), file_directory_enter_handle(), file_draw_icon(), file_draw_preview(), fileentry_uiname(), filelist_checkdir_lib(), filelist_islibrary(), filelist_readjob_list_lib(), IMB_thumb_manage(), is_filtered_lib_type(), and wm_link_append_exec().

◆ BLO_library_read_struct()

void* BLO_library_read_struct ( FileData fd,
BHead bh,
const char *  blockname 
)

◆ BLO_main_expander()

void BLO_main_expander ( BLOExpandDoitCallback  expand_doit_func)

Set the callback func used over all ID data found by BLO_expand_main func.

Parameters
expand_doit_funcCalled for each ID block it finds.

Definition at line 4472 of file readfile.c.

References expand_doit.

Referenced by BKE_blendfile_write_partial(), library_link_end(), and read_libraries().

◆ blo_make_old_idmap_from_main()

void blo_make_old_idmap_from_main ( FileData fd,
struct Main bmain 
)

Build a GSet of old main (we only care about local data here, so we can do that after blo_split_main() call.

Definition at line 1775 of file readfile.c.

References BKE_main_idmap_create(), BKE_main_idmap_destroy(), MAIN_IDMAP_TYPE_UUID, NULL, and FileData::old_idmap.

Referenced by BLO_read_from_memfile().

◆ blo_make_packed_pointer_map()

void blo_make_packed_pointer_map ( FileData fd,
Main oldmain 
)

◆ blo_read_asset_data_block()

BHead* blo_read_asset_data_block ( FileData fd,
BHead bhead,
AssetMetaData **  r_asset_data 
)

◆ BLO_read_data_globmap_add()

void BLO_read_data_globmap_add ( BlendDataReader reader,
void oldaddr,
void newaddr 
)

Definition at line 5293 of file readfile.c.

References BlendDataReader::fd, FileData::globmap, and oldnewmap_insert().

Referenced by window_manager_blend_read_data().

◆ BLO_read_data_is_undo()

bool BLO_read_data_is_undo ( BlendDataReader reader)

◆ BLO_read_data_reports()

BlendFileReadReport* BLO_read_data_reports ( BlendDataReader reader)

Definition at line 5303 of file readfile.c.

References BlendDataReader::fd, and FileData::reports.

Referenced by BKE_modifier_blend_read_data(), and link_recurs_seq().

◆ BLO_read_double_array()

void BLO_read_double_array ( BlendDataReader reader,
int  array_size,
double **  ptr_p 
)

◆ blo_read_file_internal()

BlendFileData* blo_read_file_internal ( FileData fd,
const char *  filepath 
)

Definition at line 3963 of file readfile.c.

References after_liblink_merged_bmain_process(), ATTR_FALLTHROUGH, BKE_collections_after_lib_link(), BKE_lib_override_library_main_update(), BKE_lib_override_library_main_validate(), BKE_main_id_refcount_recompute(), BKE_main_id_tag_all(), BKE_main_new(), Main::blen_thumb, BLEN_THUMB_MEMSIZE, BLEN_THUMB_MEMSIZE_FILE, BLEN_THUMB_MEMSIZE_IS_VALID, BLENFILETYPE_BLEND, BLI_addtail(), BLI_assert, blo_bhead_first(), blo_bhead_next(), blo_join_main(), BLO_READ_SKIP_DATA, BLO_READ_SKIP_USERDEF, blo_split_main(), CLOG_INFO, BHead::code, DATA, data, DNA1, do_versions(), do_versions_after_linking(), do_versions_userdef(), BlendFileReadReport::duration, ENDB, FD_FLAGS_IS_MEMFILE, Main::filepath, FileData::fileversion, fix_relpaths_library(), FileData::flags, G, GLOB, BlendThumbnail::height, height, ID_LINK_PLACEHOLDER, Main::id_map, ID_SCR, ID_SCRN, Main::is_read_invalid, ListBase::last, lib_link_all(), BlendFileReadReport::lib_overrides, LIB_TAG_LOCAL, LIB_TAG_NEW, BlendFileReadReport::libraries, link_global(), LISTBASE_FOREACH, LOG_UNDO, BlendFileData::main, FileData::mainlist, MEM_callocN, MEM_mallocN, ntreeUpdateAllNew(), NULL, PIL_check_seconds_timer(), placeholders_ensure_valid(), read_file_thumbnail(), read_global(), read_libblock(), read_libraries(), read_userdef(), BlendThumbnail::rect, FileData::relabase, REND, BlendFileReadReport::reports, FileData::reports, FileData::skip_flags, STRNCPY, TEST, BlendFileData::type, USER, Main::versionfile, BlendThumbnail::width, and width.

Referenced by BLO_read_from_file(), BLO_read_from_memfile(), and BLO_read_from_memory().

◆ BLO_read_float3_array()

void BLO_read_float3_array ( BlendDataReader reader,
int  array_size,
float **  ptr_p 
)

Definition at line 5201 of file readfile.c.

References BLO_read_float_array().

Referenced by blendRead().

◆ BLO_read_float_array()

void BLO_read_float_array ( BlendDataReader reader,
int  array_size,
float **  ptr_p 
)

◆ BLO_read_get_new_data_address()

void* BLO_read_get_new_data_address ( BlendDataReader reader,
const void old_address 
)

◆ BLO_read_get_new_data_address_no_us()

void* BLO_read_get_new_data_address_no_us ( BlendDataReader reader,
const void old_address 
)

Definition at line 5128 of file readfile.c.

References BlendDataReader::fd, and newdataadr_no_us().

Referenced by direct_link_area().

◆ blo_read_get_new_globaldata_address()

void* blo_read_get_new_globaldata_address ( struct FileData fd,
const void adr 
)

Direct data-blocks with global linking.

Note
This is rather unfortunate to have to expose this here, but better use that nasty hack in do_version than readfile itself.

Definition at line 1611 of file readfile.c.

References FileData::globmap, and oldnewmap_lookup_and_inc().

Referenced by blo_do_versions_290(), and link_global().

◆ BLO_read_get_new_id_address()

ID* BLO_read_get_new_id_address ( BlendLibReader reader,
Library lib,
ID id 
)

◆ BLO_read_get_new_packed_address()

void* BLO_read_get_new_packed_address ( BlendDataReader reader,
const void old_address 
)

Definition at line 5133 of file readfile.c.

References BlendDataReader::fd, and newpackedadr().

◆ BLO_read_glob_list()

void BLO_read_glob_list ( BlendDataReader reader,
ListBase list 
)

Definition at line 5298 of file readfile.c.

References BlendDataReader::fd, and link_glob_list().

Referenced by scene_blend_read_data().

◆ BLO_read_int32_array()

void BLO_read_int32_array ( BlendDataReader reader,
int  array_size,
int32_t **  ptr_p 
)

◆ BLO_read_lib_get_main()

Main* BLO_read_lib_get_main ( BlendLibReader reader)

◆ BLO_read_lib_is_undo()

bool BLO_read_lib_is_undo ( BlendLibReader reader)

Definition at line 5308 of file readfile.c.

References BlendLibReader::fd, FD_FLAGS_IS_MEMFILE, and FileData::flags.

Referenced by BKE_pose_blend_read_lib(), and ntreeBlendReadLib().

◆ BLO_read_lib_reports()

BlendFileReadReport* BLO_read_lib_reports ( BlendLibReader reader)

Definition at line 5318 of file readfile.c.

References BlendLibReader::fd, and FileData::reports.

Referenced by object_blend_read_lib(), and scene_blend_read_lib().

◆ BLO_read_list()

void BLO_read_list ( BlendDataReader reader,
struct ListBase list 
)

Definition at line 5172 of file readfile.c.

References BLO_read_list_cb(), and NULL.

Referenced by action_blend_read_data(), armature_blend_read_data(), BKE_animdata_blend_read_data(), BKE_asset_metadata_read(), BKE_collection_blend_read_data(), BKE_constraint_blend_read_data(), BKE_fcurve_blend_read_data(), BKE_gpencil_blend_read_data(), BKE_gpencil_modifier_blend_read_data(), BKE_keyingsets_blend_read_data(), BKE_modifier_blend_read_data(), BKE_nla_blend_read_data(), BKE_particle_system_blend_read_data(), BKE_pose_blend_read_data(), BKE_ptcache_blend_read_data(), BKE_screen_area_map_blend_read_data(), BKE_shaderfx_blend_read_data(), BKE_view_layer_blend_read_data(), blend_data_read_nla_strips(), cache_file_blend_read_data(), camera_blend_read_data(), curve_blend_read_data(), direct_link_area(), direct_link_bones(), direct_link_layer_collections(), direct_link_moviePlaneTracks(), direct_link_movieTracks(), direct_link_nlastrips(), direct_link_panel_list(), direct_link_pointcache_cb(), direct_link_region(), IDP_DirectLinkGroup(), image_blend_read_data(), ipo_blend_read_data(), lattice_blend_read_data(), linestyle_blend_read_data(), link_recurs_seq(), mask_blend_read_data(), mesh_blend_read_data(), metaball_blend_read_data(), movieclip_blend_read_data(), ntreeBlendReadData(), object_blend_read_data(), palette_blend_read_data(), particle_settings_blend_read_data(), read_userdef(), scene_blend_read_data(), SEQ_modifier_blend_read_data(), seq_read_data_cb(), shapekey_blend_read_data(), text_blend_read_data(), window_manager_blend_read_data(), and workspace_blend_read_data().

◆ BLO_read_list_cb()

void BLO_read_list_cb ( BlendDataReader reader,
struct ListBase list,
BlendReadListFn  callback 
)

Updates all ->prev and ->next pointers of the list elements. Updates the list->first and list->last pointers. When not NULL, calls the callback on every element.

Definition at line 5148 of file readfile.c.

References BLI_listbase_is_empty(), BLO_read_data_address, callback, ListBase::first, ListBase::last, Link::next, NULL, blender::meshintersect::prev(), and Link::prev.

Referenced by BLO_read_list(), direct_link_id_common(), direct_link_id_override_property_cb(), and direct_link_pointcache().

◆ BLO_read_pointer_array()

void BLO_read_pointer_array ( BlendDataReader reader,
void **  ptr_p 
)

◆ BLO_read_requires_endian_switch()

bool BLO_read_requires_endian_switch ( BlendDataReader reader)

◆ BLO_read_uint32_array()

void BLO_read_uint32_array ( BlendDataReader reader,
int  array_size,
uint32_t **  ptr_p 
)

◆ blo_readfile_invalidate()

void blo_readfile_invalidate ( FileData fd,
Main bmain,
const char *  message 
)

◆ BLO_reportf_wrap()

void BLO_reportf_wrap ( BlendFileReadReport reports,
eReportType  type,
const char *  format,
  ... 
)

◆ blo_split_main()

void blo_split_main ( ListBase mainlist,
Main main 
)

◆ BLO_thumbnail_from_file()

BlendThumbnail* BLO_thumbnail_from_file ( const char *  filepath)

Does a very light reading of given .blend file to extract its stored thumbnail.

Parameters
filepathThe path of the file to extract thumbnail from.
Returns
The raw thumbnail (MEM-allocated, as stored in file, use BKE_main_thumbnail_to_imbuf() to convert it to ImBuf image).

Definition at line 1563 of file readfile.c.

References BLEN_THUMB_MEMSIZE, BLEN_THUMB_MEMSIZE_FILE, BLEN_THUMB_MEMSIZE_IS_VALID, BLI_assert, blo_filedata_free(), blo_filedata_from_file_minimal(), data, height, MEM_mallocN, NULL, read_file_thumbnail(), and width.

Referenced by imb_thumb_load_from_blendfile().

◆ change_link_placeholder_to_real_ID_pointer()

static void change_link_placeholder_to_real_ID_pointer ( ListBase mainlist,
FileData basefd,
void old,
void new 
)
static

◆ change_link_placeholder_to_real_ID_pointer_fd()

static void change_link_placeholder_to_real_ID_pointer_fd ( FileData fd,
const void old,
void new 
)
static

◆ convert_pointer_array_32_to_64()

static void convert_pointer_array_32_to_64 ( BlendDataReader UNUSEDreader,
uint  array_size,
const uint32_t src,
uint64_t dst 
)
static

Definition at line 5234 of file readfile.c.

References src.

Referenced by BLO_read_pointer_array().

◆ convert_pointer_array_64_to_32()

static void convert_pointer_array_64_to_32 ( BlendDataReader reader,
uint  array_size,
const uint64_t src,
uint32_t dst 
)
static

Definition at line 5214 of file readfile.c.

References BLI_endian_switch_uint64(), BLO_read_requires_endian_switch(), ptr, and src.

Referenced by BLO_read_pointer_array().

◆ create_placeholder()

static ID* create_placeholder ( Main mainvar,
const short  idcode,
const char *  idname,
const int  tag 
)
static

◆ dataname()

static const char* dataname ( short  id_code)
static

◆ decode_blender_header()

static void decode_blender_header ( FileData fd)
static

◆ direct_link_id()

static bool direct_link_id ( FileData fd,
Main main,
const int  tag,
ID id,
ID id_old 
)
static

◆ direct_link_id_common()

static void direct_link_id_common ( BlendDataReader reader,
Library current_library,
ID id,
ID id_old,
const int  tag 
)
static

◆ direct_link_id_embedded_id()

static void direct_link_id_embedded_id ( BlendDataReader reader,
Library current_library,
ID id,
ID id_old 
)
static

◆ direct_link_id_override_property_cb()

static void direct_link_id_override_property_cb ( BlendDataReader reader,
void data 
)
static

◆ direct_link_id_override_property_operation_cb()

static void direct_link_id_override_property_operation_cb ( BlendDataReader reader,
void data 
)
static

◆ direct_link_id_restore_recalc()

static int direct_link_id_restore_recalc ( const FileData fd,
const ID id_target,
const ID id_current,
const bool  is_identical 
)
static

◆ direct_link_id_restore_recalc_exceptions()

static int direct_link_id_restore_recalc_exceptions ( const ID id_current)
static

◆ direct_link_keymapitem()

static void direct_link_keymapitem ( BlendDataReader reader,
wmKeyMapItem kmi 
)
static

◆ direct_link_library()

static void direct_link_library ( FileData fd,
Library lib,
Main main 
)
static

◆ do_versions()

static void do_versions ( FileData fd,
Library lib,
Main main 
)
static

◆ do_versions_after_linking()

static void do_versions_after_linking ( FileData fd,
Main main 
)
static

◆ do_versions_userdef()

static void do_versions_userdef ( FileData UNUSEDfd,
BlendFileData bfd 
)
static

Definition at line 3652 of file readfile.c.

References blo_do_versions_userdef(), NULL, and BlendFileData::user.

Referenced by blo_read_file_internal().

◆ expand_doit_library()

static void expand_doit_library ( void fdhandle,
Main mainvar,
void old 
)
static

◆ expand_id()

static void expand_id ( BlendExpander expander,
ID id 
)
static

◆ expand_id_embedded_id()

static void expand_id_embedded_id ( BlendExpander expander,
ID id 
)
static

◆ file_global_minversion_hotfix()

static void file_global_minversion_hotfix ( FileGlobal fg)
static

◆ filedata_new()

static FileData* filedata_new ( BlendFileReadReport reports)
static

◆ find_bhead()

static BHead* find_bhead ( FileData fd,
void old 
)
static

◆ find_bhead_from_code_name()

static BHead * find_bhead_from_code_name ( FileData fd,
const short  idcode,
const char *  name 
)
static

◆ find_bhead_from_idname()

static BHead * find_bhead_from_idname ( FileData fd,
const char *  idname 
)
static

◆ find_previous_lib()

static BHead* find_previous_lib ( FileData fd,
BHead bhead 
)
static

◆ fix_relpaths_library()

static void fix_relpaths_library ( const char *  basepath,
Main main 
)
static

◆ get_bhead()

static BHeadN* get_bhead ( FileData fd)
static

◆ has_linked_ids_to_read()

static int has_linked_ids_to_read ( Main mainvar)
static

◆ insert_packedmap()

static void insert_packedmap ( FileData fd,
PackedFile pf 
)
static

Definition at line 1676 of file readfile.c.

References oldnewmap_insert(), FileData::packedmap, and pf.

Referenced by blo_make_packed_pointer_map().

◆ is_minversion_older_than_blender()

static bool is_minversion_older_than_blender ( FileData fd,
ReportList reports 
)
static

◆ is_yet_read()

static ID* is_yet_read ( FileData fd,
Main mainvar,
BHead bhead 
)
static

◆ lib_link_all()

static void lib_link_all ( FileData fd,
Main bmain 
)
static

◆ lib_link_clipboard_restore()

static void lib_link_clipboard_restore ( struct IDNameLib_Map id_map)
static

◆ lib_link_id()

static void lib_link_id ( BlendLibReader reader,
ID id 
)
static

◆ lib_link_id_embedded_id()

static void lib_link_id_embedded_id ( BlendLibReader reader,
ID id 
)
static

◆ lib_link_library()

static void lib_link_library ( BlendLibReader UNUSEDreader,
Library UNUSEDlib 
)
static

Definition at line 2942 of file readfile.c.

Referenced by lib_link_all().

◆ lib_link_main_data_restore()

static void lib_link_main_data_restore ( struct IDNameLib_Map id_map,
Main newmain 
)
static

◆ lib_link_main_data_restore_cb()

static int lib_link_main_data_restore_cb ( LibraryIDLinkCallbackData cb_data)
static

◆ lib_link_scenes_check_set()

static void lib_link_scenes_check_set ( Main bmain)
static

◆ lib_link_seq_clipboard_cb()

static bool lib_link_seq_clipboard_cb ( Sequence seq,
void arg_pt 
)
static

◆ lib_link_seq_clipboard_pt_restore()

static void lib_link_seq_clipboard_pt_restore ( ID id,
struct IDNameLib_Map id_map 
)
static

Definition at line 2470 of file readfile.c.

References BLI_assert, id, ID::newid, NULL, restore_pointer_by_name(), and USER_REAL.

Referenced by lib_link_seq_clipboard_cb().

◆ lib_link_window_scene_data_restore()

static void lib_link_window_scene_data_restore ( wmWindow win,
Scene scene,
ViewLayer view_layer 
)
static

◆ lib_link_wm_xr_data_restore()

static void lib_link_wm_xr_data_restore ( struct IDNameLib_Map id_map,
wmXrData xr_data 
)
static

◆ lib_link_workspace_layout_restore()

static void lib_link_workspace_layout_restore ( struct IDNameLib_Map id_map,
Main newmain,
WorkSpaceLayout layout 
)
static

Definition at line 2592 of file readfile.c.

References SpaceAction::action, SpaceAction::ads, SpaceGraph::ads, SpaceNla::ads, blender::compositor::area(), bScreen::areabase, BKE_workspace_layout_screen_get(), BLI_mempool_iternew(), BLI_mempool_iterstep(), BLI_remlink(), View3D::camera, SpaceClip::clip, blender::compositor::context, SpaceSpreadsheet::context_path, SpaceNode::edittree, FILE_TAG_REBUILD_MAIN_FILES, bDopeSheet::filter_grp, ListBase::first, SpaceAction_Runtime::flag, SpaceProperties::flag, SpaceGraph_Runtime::flag, SpaceNode::from, SpaceSeq::gpd, SpaceImage::gpd, TreeStoreElem::id, SpaceNode::id, SpaceImage::image, SpaceImage::iuser, ListBase::last, LISTBASE_FOREACH, MaskSpaceInfo::mask, SpaceImage::mask_info, SpaceClip::mask_info, MEM_freeN, MEM_SAFE_FREE, bNodeTreePath::next, bNodeTreePath::nodetree, SpaceNode::nodetree, ntree, ntreeFromID(), NULL, View3D::ob_center, SpreadsheetContextObject::object, Scopes::ok, MovieClipScopes::ok, SpaceFile::op, SpaceProperties::path, SpaceProperties::pinid, restore_pointer_by_name(), SpaceAction::runtime, SpaceGraph::runtime, SACTION_RUNTIME_FLAG_NEED_CHAN_SYNC, SB_PIN_CONTEXT, ImageUser::scene, SpaceImage::scopes, SpaceClip::scopes, SpaceScript::script, SCRIPT_SET_NULL, SpaceOutliner::search_tse, SIPO_RUNTIME_FLAG_NEED_CHAN_SYNC_COLOR, SO_TREESTORE_REBUILD, bDopeSheet::source, SPACE_ACTION, SPACE_CLIP, SPACE_FILE, SPACE_GRAPH, SPACE_IMAGE, SPACE_NLA, SPACE_NODE, SPACE_OUTLINER, SPACE_PROPERTIES, SPACE_SCRIPT, SPACE_SEQ, SPACE_SPREADSHEET, SPACE_TEXT, SPACE_VIEW3D, SPREADSHEET_CONTEXT_OBJECT, usdtokens::st(), SpaceOutliner::storeflag, SpaceFile::tags, Main::texts, SpaceNode::treepath, SpaceOutliner::treestore, TSE_IS_REAL_ID, USER_IGNORE, USER_REAL, Scopes::vecscope, Scopes::waveform_1, Scopes::waveform_2, and Scopes::waveform_3.

Referenced by blo_lib_link_restore().

◆ library_link_begin()

static Main* library_link_begin ( Main mainvar,
FileData **  fd,
const char *  filepath,
const int  id_tag_extra 
)
static

◆ library_link_end()

static void library_link_end ( Main mainl,
FileData **  fd,
const int  flag 
)
static

◆ library_parent_filepath()

static const char* library_parent_filepath ( Library lib)
static

Definition at line 224 of file readfile.c.

References lib.

Referenced by read_library_file_data(), and read_library_linked_id().

◆ link_glob_list()

static void link_glob_list ( FileData fd,
ListBase lb 
)
static

◆ link_global()

static void link_global ( FileData fd,
BlendFileData bfd 
)
static

◆ link_named_part()

static ID* link_named_part ( Main mainl,
FileData fd,
const short  idcode,
const char *  name,
const int  flag 
)
static

◆ newdataadr()

static void* newdataadr ( FileData fd,
const void adr 
)
static

◆ newdataadr_no_us()

static void* newdataadr_no_us ( FileData fd,
const void adr 
)
static

Definition at line 1606 of file readfile.c.

References FileData::datamap, and oldnewmap_lookup_and_inc().

Referenced by BLO_read_get_new_data_address_no_us().

◆ newlibadr()

static void* newlibadr ( FileData fd,
const void lib,
const void adr 
)
static

◆ newpackedadr()

static void* newpackedadr ( FileData fd,
const void adr 
)
static

◆ oldnewmap_clear()

static void oldnewmap_clear ( OldNewMap onm)
static

◆ oldnewmap_clear_map()

static void oldnewmap_clear_map ( OldNewMap onm)
static

Definition at line 308 of file readfile.c.

References OldNewMap::map, and MAP_CAPACITY.

Referenced by oldnewmap_increase_size(), and oldnewmap_init_data().

◆ oldnewmap_free()

static void oldnewmap_free ( OldNewMap onm)
static

Definition at line 419 of file readfile.c.

References OldNewMap::entries, OldNewMap::map, and MEM_freeN.

Referenced by blo_filedata_free(), and read_library_file_data().

◆ oldnewmap_increase_size()

static void oldnewmap_increase_size ( OldNewMap onm)
static

◆ oldnewmap_init_data()

static void oldnewmap_init_data ( OldNewMap onm,
const int  capacity_exp 
)
static

◆ oldnewmap_insert()

static void oldnewmap_insert ( OldNewMap onm,
const void oldaddr,
void newaddr,
int  nr 
)
static

◆ oldnewmap_insert_index_in_map()

static void oldnewmap_insert_index_in_map ( OldNewMap onm,
const void ptr,
int  index 
)
static

Definition at line 267 of file readfile.c.

References ITER_SLOTS, OldNewMap::map, and ptr.

Referenced by oldnewmap_increase_size().

◆ oldnewmap_insert_or_replace()

static void oldnewmap_insert_or_replace ( OldNewMap onm,
OldNew  entry 
)
static

Definition at line 277 of file readfile.c.

References OldNewMap::entries, ITER_SLOTS, OldNewMap::map, OldNewMap::nentries, and OldNew::oldp.

Referenced by oldnewmap_insert().

◆ oldnewmap_lib_insert()

static void oldnewmap_lib_insert ( FileData fd,
const void oldaddr,
ID newaddr,
int  nr 
)
static

◆ oldnewmap_liblookup()

static void* oldnewmap_liblookup ( OldNewMap onm,
const void addr,
const void lib 
)
static

Definition at line 386 of file readfile.c.

References id, lib, ID::lib, NULL, and oldnewmap_lookup_and_inc().

Referenced by newlibadr().

◆ oldnewmap_lookup_and_inc()

static void* oldnewmap_lookup_and_inc ( OldNewMap onm,
const void addr,
bool  increase_users 
)
static

◆ oldnewmap_lookup_entry()

static OldNew* oldnewmap_lookup_entry ( const OldNewMap onm,
const void addr 
)
static

Definition at line 293 of file readfile.c.

References OldNewMap::entries, ITER_SLOTS, NULL, and OldNew::oldp.

Referenced by oldnewmap_lookup_and_inc().

◆ oldnewmap_new()

static OldNewMap* oldnewmap_new ( void  )
static

◆ peek_struct_undo()

static const void* peek_struct_undo ( FileData fd,
BHead bhead 
)
static

◆ placeholders_ensure_valid()

static void placeholders_ensure_valid ( Main bmain)
static

◆ read_data_into_datamap()

static BHead* read_data_into_datamap ( FileData fd,
BHead bhead,
const char *  allocname 
)
static

◆ read_file_bhead_idname_map_create()

static void read_file_bhead_idname_map_create ( FileData fd)
static

◆ read_file_dna()

static bool read_file_dna ( FileData fd,
const char **  r_error_message 
)
static

◆ read_file_thumbnail()

static int* read_file_thumbnail ( FileData fd)
static

◆ read_file_version()

static void read_file_version ( FileData fd,
Main main 
)
static

◆ read_global()

static BHead* read_global ( BlendFileData bfd,
FileData fd,
BHead bhead 
)
static

◆ read_libblock()

static BHead* read_libblock ( FileData fd,
Main main,
BHead bhead,
const int  tag,
const bool  placeholder_set_indirect_extern,
ID **  r_id 
)
static

◆ read_libblock_is_identical()

static bool read_libblock_is_identical ( FileData fd,
BHead bhead 
)
static

Definition at line 3185 of file readfile.c.

References BHEADN_FROM_BHEAD, blo_bhead_next(), BHead::code, DATA, and BHead::len.

Referenced by read_libblock_undo_restore().

◆ read_libblock_undo_restore()

static bool read_libblock_undo_restore ( FileData fd,
Main main,
BHead bhead,
const int  tag,
ID **  r_id_old 
)
static

◆ read_libblock_undo_restore_at_old_address()

static void read_libblock_undo_restore_at_old_address ( FileData fd,
Main main,
ID id,
ID id_old 
)
static

◆ read_libblock_undo_restore_identical()

static void read_libblock_undo_restore_identical ( FileData fd,
Main main,
const ID UNUSEDid,
ID id_old,
const int  tag 
)
static

◆ read_libblock_undo_restore_library()

static bool read_libblock_undo_restore_library ( FileData fd,
Main main,
const ID id 
)
static

◆ read_libblock_undo_restore_linked()

static bool read_libblock_undo_restore_linked ( FileData fd,
Main main,
const ID id,
BHead bhead 
)
static

◆ read_libraries()

static void read_libraries ( FileData basefd,
ListBase mainlist 
)
static

◆ read_library_clear_weak_links()

static void read_library_clear_weak_links ( FileData basefd,
ListBase mainlist,
Main mainvar 
)
static

◆ read_library_file_data()

static FileData* read_library_file_data ( FileData basefd,
ListBase mainlist,
Main mainl,
Main mainptr 
)
static

◆ read_library_linked_id()

static void read_library_linked_id ( FileData basefd,
FileData fd,
Main mainvar,
ID id,
ID **  r_id 
)
static

◆ read_library_linked_ids()

static void read_library_linked_ids ( FileData basefd,
FileData fd,
ListBase mainlist,
Main mainvar 
)
static

◆ read_struct()

static void * read_struct ( FileData fd,
BHead bh,
const char *  blockname 
)
static

◆ read_userdef()

static BHead* read_userdef ( BlendFileData bfd,
FileData fd,
BHead bhead 
)
static

◆ restore_pointer_by_name()

static void* restore_pointer_by_name ( struct IDNameLib_Map id_map,
ID id,
ePointerUserMode  user 
)
static

Only for undo files, or to restore a screen after reading without UI...

Parameters
user
  • USER_IGNORE: no user-count change.
  • USER_REAL: ensure a real user (even if a fake one is set).
id_maplookup table, use when performing many lookups. this could be made an optional argument (falling back to a full lookup), however at the moment it's always available.

Definition at line 2452 of file readfile.c.

References BKE_main_idmap_lookup_id(), BKE_main_idmap_main_get(), NULL, and restore_pointer_user().

Referenced by blo_lib_link_restore(), lib_link_main_data_restore_cb(), lib_link_seq_clipboard_pt_restore(), lib_link_wm_xr_data_restore(), and lib_link_workspace_layout_restore().

◆ restore_pointer_user()

static void restore_pointer_user ( ID id,
ID newid,
ePointerUserMode  user 
)
static

Definition at line 2404 of file readfile.c.

References BLI_assert, id, id_us_ensure_real(), ID::lib, ID::name, STREQ, UNUSED_VARS_NDEBUG, and USER_REAL.

Referenced by restore_pointer_by_name().

◆ sort_bhead_old_map()

static void sort_bhead_old_map ( FileData fd)
static

◆ split_libdata()

static void split_libdata ( ListBase lb_src,
Main **  lib_main_array,
const uint  lib_main_array_len 
)
static

◆ split_main_newid()

static void split_main_newid ( Main mainptr,
Main main_newid 
)
static

◆ switch_endian_bh4()

static void switch_endian_bh4 ( BHead4 bhead)
static

Definition at line 728 of file readfile.c.

References BLI_endian_switch_int32(), BHead4::code, ENDB, BHead4::len, BHead4::nr, and BHead4::SDNAnr.

Referenced by get_bhead().

◆ switch_endian_bh8()

static void switch_endian_bh8 ( BHead8 bhead)
static

Definition at line 742 of file readfile.c.

References BLI_endian_switch_int32(), BHead8::code, ENDB, BHead8::len, BHead8::nr, and BHead8::SDNAnr.

Referenced by get_bhead().

◆ switch_endian_structs()

static void switch_endian_structs ( const struct SDNA filesdna,
BHead bhead 
)
static

◆ verg_bheadsort()

static int verg_bheadsort ( const void v1,
const void v2 
)
static

Definition at line 4168 of file readfile.c.

References BHeadSort::old, v1, v2, and x2.

Referenced by find_bhead(), and sort_bhead_old_map().

Variable Documentation

◆ expand_doit

BLOExpandDoitCallback expand_doit
static

Definition at line 4433 of file readfile.c.

Referenced by BLO_expand_id(), and BLO_main_expander().

◆ LOG

CLG_LogRef LOG = {"blo.readfile"}
static

◆ LOG_UNDO

CLG_LogRef LOG_UNDO = {"blo.readfile.undo"}
static