diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-03-16 17:57:00 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-03-18 13:09:15 +0300 |
commit | 8ab52daa3aafcec7c8780653090c2be49eeb6748 (patch) | |
tree | 570d7a0030b81609b5880b1e2714efb62339bbf5 /source/blender/blenloader/BLO_readfile.h | |
parent | aeff59073b23d50a39eb0a614d3907ac0d04994a (diff) |
BLO: Functions for temporarily loading a single datablock
This introduces two functions to the blenloader module, here shown as
calls for brevity:
* `temp_lib_ctx = BLO_library_temp_load_id(real_main, blend_file_path, idcode, idname, reports);`
* Now the data in `temp_lib_ctx->temp_id` can be used (but ought not to
be not assigned to non-temp datablocks).
* `BLO_library_temp_free(temp_lib_ctx);`
The first loads a datablock from a blend file, and returns it as part of
a `struct TempLibraryContext`. This struct contains the temp-loaded ID,
as well as enough information to correctly free everything again.
Differential Revision: https://developer.blender.org/D10736
Diffstat (limited to 'source/blender/blenloader/BLO_readfile.h')
-rw-r--r-- | source/blender/blenloader/BLO_readfile.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 09f4c405613..d8c613ba900 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -18,6 +18,7 @@ */ #pragma once +#include "BLI_listbase.h" #include "BLI_sys_types.h" /** \file @@ -221,6 +222,26 @@ void BLO_library_link_end(struct Main *mainl, int BLO_library_link_copypaste(struct Main *mainl, BlendHandle *bh, const uint64_t id_types_mask); +/** + * Struct for temporarily loading datablocks from a blend file. + */ +typedef struct TempLibraryContext { + struct Main *temp_main; + struct BlendHandle *blendhandle; + struct LibraryLink_Params liblink_params; + struct Library *lib; + + /* The ID datablock that was loaded. Is NULL if loading failed. */ + struct ID *temp_id; +} TempLibraryContext; + +TempLibraryContext *BLO_library_temp_load_id(struct Main *real_main, + const char *blend_file_path, + const short idcode, + const char *idname, + struct ReportList *reports); +void BLO_library_temp_free(TempLibraryContext *temp_lib_ctx); + /** \} */ void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname); |