54 this->
lock = (MainLock *)main_lock;
69 if (main_it ==
this) {
72 main_it->split_mains.reset();
79 "'.blend' relative \"//\" must not be used in Main!");
91 Main *bmain = MEM_new<Main>(__func__);
108 int a = lbarray.size();
113 for (
id =
static_cast<ID *
>(lb->
first);
id !=
nullptr;
id = id_next) {
114 id_next =
static_cast<ID *
>(
id->next);
121# define CASE_ID_INDEX(id_index) \
123 BKE_id_free_ex(&bmain, id, free_flag, false); \
142 CASE_ID_INDEX(INDEX_ID_SIM);
222 if (lib_1 && lib_2) {
252 if (!id_1->
lib && !id_2->
lib) {
256 if (id_1->
lib && id_2->
lib) {
257 if (id_1->
lib == id_2->
lib) {
291 const bool is_library,
294 const bool is_id_src_linked(id_src->
lib);
295 bool is_id_src_from_bmain_dst =
false;
296 if (is_id_src_linked) {
303 is_id_src_from_bmain_dst = !id_src_lib_dst.
is_empty() && !id_src_lib_dst[0];
305 std::cout << id_src->
name <<
" is linked from dst Main: " << is_id_src_from_bmain_dst <<
"\n";
308 if (is_id_src_from_bmain_dst) {
314 "ID '%s' defined in source Main as linked from destination Main (file '%s') not "
315 "found in given destination Main",
318 id_remapper.
add(id_src,
nullptr);
322 ids_to_move.
append(id_src);
328 Main *bmain_src = *r_bmain_src;
331 ID *id_iter_dst, *id_iter_src;
338 id_map_dst.
add(lib_dst->
runtime->filepath_abs, {id_iter_dst});
357 const bool is_library =
GS(id_iter_src->
name) ==
ID_LI;
360 is_library ?
reinterpret_cast<Library *
>(id_iter_src)->runtime->filepath_abs :
368 bmain_dst, id_map_dst, id_iter_src, id_remapper, ids_to_move, is_library, reports);
372 bool src_has_match_in_dst =
false;
373 for (
ID *id_iter_dst : ids_dst) {
377 if (!src_has_match_in_dst) {
379 id_remapper_libraries.
add(id_iter_src, id_iter_dst);
383 id_remapper.
add(id_iter_src, id_iter_dst);
386 src_has_match_in_dst =
true;
393 if (!src_has_match_in_dst) {
395 bmain_dst, id_map_dst, id_iter_src, id_remapper, ids_to_move, is_library, reports);
404 if (bmain_src->
filepath[0] !=
'\0') {
409 if (bmain_dst->
filepath[0] !=
'\0') {
426 id_remapper_libraries,
429 for (
ID *id_iter_src : ids_to_move) {
442 "Merged %d IDs from '%s' Main into '%s' Main; %d IDs and %d Libraries already existed as "
443 "part of the destination Main, and %d IDs missing from destination Main, were freed "
444 "together with the source Main",
459 *r_bmain_src =
nullptr;
519 to_id_entry->
next = (*entry_p)->to_ids;
521 to_id_entry->
session_uid = (*id_pointer !=
nullptr) ? (*id_pointer)->session_uid :
524 (*entry_p)->to_ids = to_id_entry;
528 if (*id_pointer !=
nullptr) {
533 (*entry_p)->session_uid = (*id_pointer)->session_uid;
536 BLI_assert((*entry_p)->session_uid == (*id_pointer)->session_uid);
540 from_id_entry->
next = (*entry_p)->from_ids;
544 (*entry_p)->from_ids = from_id_entry;
576 (*entry_p)->session_uid =
id->session_uid;
625 if (gset ==
nullptr) {
644 STRNCPY(this->filepath, lib_path);
666 auto *library_weak_reference_mapping = MEM_new<MainLibraryWeakReferenceMap>(__func__);
670 ID *id_iter =
static_cast<ID *
>(lb->
first);
671 if (id_iter ==
nullptr) {
685 library_weak_reference_mapping->map.add(key, id_iter);
691 return library_weak_reference_mapping;
697 MEM_delete(library_weak_reference_mapping);
702 const char *library_filepath,
703 const char *library_id_name)
711 const char *library_filepath,
712 const char *library_id_name,
728 library_weak_reference_mapping->
map.
add(key, new_id);
735 const char *library_filepath,
736 const char *library_id_name,
757 const char *library_filepath,
758 const char *library_id_name,
767 library_weak_reference_mapping->
map.
remove(key);
773 const char *library_filepath,
774 const char *library_id_name)
777 char library_filepath_abs[
FILE_MAX];
778 STRNCPY(library_filepath_abs, library_filepath);
783 if (!(existing_id->library_weak_reference &&
784 STREQ(existing_id->library_weak_reference->library_id_name, library_id_name)))
789 char existing_filepath_abs[
FILE_MAX];
790 STRNCPY(existing_filepath_abs, existing_id->library_weak_reference->library_filepath);
793 if (!
STREQ(existing_filepath_abs, library_filepath_abs)) {
804 const char *library_filepath,
805 const char *library_id_name)
828 memcpy(
data->rect, rect, data_size -
sizeof(*
data));
850 data->width = img->
x;
851 data->height = img->
y;
863 ImBuf *img =
nullptr;
865 if (!
data && bmain) {
899 return library.runtime->filepath_abs;
936 return &(bmain->
fonts);
938 return &(bmain->
texts);
966 return &(bmain->
masks);
void BKE_bpath_absolute_convert(Main *bmain, const char *basedir, ReportList *reports, BPathSummary *r_summary=nullptr)
void BKE_bpath_relative_rebase(Main *bmain, const char *basedir_src, const char *basedir_dst, ReportList *reports, BPathSummary *r_summary=nullptr)
bool BKE_idtype_idcode_is_linkable(short idcode)
bool BKE_idtype_idcode_append_is_reusable(short idcode)
void BKE_libblock_management_main_remove(Main *bmain, void *idv)
#define MAIN_ID_SESSION_UID_UNSET
@ LIB_ID_FREE_NO_USER_REFCOUNT
void BKE_id_free_ex(Main *bmain, void *idv, int flag_orig, bool use_flag_from_idtag)
void BKE_libblock_management_main_add(Main *bmain, void *idv)
LibraryForeachIDCallbackFlag
void BKE_library_foreach_ID_link(Main *bmain, ID *id, blender::FunctionRef< LibraryIDLinkCallback > callback, void *user_data, LibraryForeachIDFlag flag)
void BKE_libblock_relink_multiple(Main *bmain, const blender::Span< ID * > ids, eIDRemapType remap_type, blender::bke::id::IDRemapper &id_remapper, int remap_flags)
@ ID_REMAP_DO_LIBRARY_POINTERS
#define FOREACH_MAIN_ID_END
void BKE_main_clear(Main &bmain)
#define FOREACH_MAIN_LISTBASE_ID_END
std::array< ListBase *, INDEX_ID_MAX - 1 > MainListsArray
@ MAINIDRELATIONS_INCLUDE_UI
#define FOREACH_MAIN_LISTBASE_ID_BEGIN(_lb, _id)
#define FOREACH_MAIN_LISTBASE_END
eMainIDRelationsEntryTags
#define FOREACH_MAIN_LISTBASE_BEGIN(_bmain, _lb)
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
#define BLEN_THUMB_MEMSIZE(_x, _y)
void BKE_main_idmap_destroy(IDNameLib_Map *id_map) ATTR_NONNULL()
void BKE_main_namemap_destroy(UniqueName_Map **r_name_map) ATTR_NONNULL()
void BKE_main_namemap_clear(Main &bmain)
bool BKE_main_namemap_validate(Main &bmain)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
void BLI_ghashIterator_step(GHashIterator *ghi)
unsigned int BLI_ghashutil_ptrhash(const void *key)
void BLI_ghashIterator_free(GHashIterator *ghi)
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
GHash * BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GHashIterator * BLI_ghashIterator_new(GHash *gh) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
GSet * BLI_gset_new(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
bool BLI_ghashutil_ptrcmp(const void *a, const void *b)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
bool BLI_ghash_ensure_p(GHash *gh, void *key, void ***r_val) ATTR_WARN_UNUSED_RESULT
bool BLI_gset_add(GSet *gs, void *key)
BLI_INLINE bool BLI_ghashIterator_done(const GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
BLI_mempool * BLI_mempool_create(unsigned int esize, unsigned int elem_num, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
void void BLI_path_split_dir_part(const char *filepath, char *dir, size_t dir_maxncpy) ATTR_NONNULL(1
int BLI_path_normalize_native(char *path) ATTR_NONNULL(1)
char * STRNCPY(char(&dst)[N], const char *src)
pthread_spinlock_t SpinLock
void BLI_spin_init(SpinLock *spin)
void BLI_spin_unlock(SpinLock *spin)
void BLI_spin_lock(SpinLock *spin)
void BLI_spin_end(SpinLock *spin)
#define UNUSED_VARS_NDEBUG(...)
#define CLOG_WARN(clg_ref,...)
ID and Library types, which are fundamental for SDNA.
#define ID_IS_LINKED(_id)
void IMB_colormanagement_working_space_init_default(Main *bmain)
ImBuf * IMB_allocFromBuffer(const uint8_t *byte_buffer, const float *float_buffer, unsigned int w, unsigned int h, unsigned int channels)
void IMB_byte_from_float(ImBuf *ibuf)
Read Guarded memory(de)allocation.
BMesh const char void * data
unsigned long long int uint64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
bool add_overwrite(const Key &key, const Value &value)
bool add(const Key &key, const Value &value)
const Value & lookup(const Key &key) const
Value lookup_default(const Key &key, const Value &default_value) const
bool remove(const Key &key)
bool add(const Key &key, const Value &value)
Value lookup_default(const Key &key, const Value &default_value) const
bool contains(const Key &key) const
Value & lookup_or_add(const Key &key, const Value &value)
void append(const T &value)
void add(ID *old_id, ID *new_id)
ID * BKE_main_library_weak_reference_search_item(MainLibraryWeakReferenceMap *library_weak_reference_mapping, const char *library_filepath, const char *library_id_name)
MainListsArray BKE_main_lists_get(Main &bmain)
BlendThumbnail * BKE_main_thumbnail_from_imbuf(Main *bmain, ImBuf *img)
ListBase * which_libbase(Main *bmain, short type)
void BKE_main_clear(Main &bmain)
void BKE_main_merge(Main *bmain_dst, Main **r_bmain_src, MainMergeReport &reports)
void BKE_main_library_weak_reference_remove_item(MainLibraryWeakReferenceMap *library_weak_reference_mapping, const char *library_filepath, const char *library_id_name, ID *old_id)
void BKE_main_library_weak_reference_add(ID *local_id, const char *library_filepath, const char *library_id_name)
bool BKE_main_needs_overwrite_confirm(const Main *bmain)
bool BKE_main_has_issues(const Main *bmain)
void BKE_main_lock(Main *bmain)
void BKE_main_relations_tag_set(Main *bmain, const eMainIDRelationsEntryTags tag, const bool value)
void BKE_main_thumbnail_create(Main *bmain)
ImBuf * BKE_main_thumbnail_to_imbuf(Main *bmain, BlendThumbnail *data)
const char * BKE_main_blendfile_path_from_library(const Library &library)
void BKE_main_relations_create(Main *bmain, const short flag)
MainLibraryWeakReferenceMap * BKE_main_library_weak_reference_create(Main *bmain)
void BKE_main_library_weak_reference_add_item(MainLibraryWeakReferenceMap *library_weak_reference_mapping, const char *library_filepath, const char *library_id_name, ID *new_id)
void BKE_main_free(Main *bmain)
void BKE_main_library_weak_reference_destroy(MainLibraryWeakReferenceMap *library_weak_reference_mapping)
void BKE_main_library_weak_reference_update_item(MainLibraryWeakReferenceMap *library_weak_reference_mapping, const char *library_filepath, const char *library_id_name, ID *old_id, ID *new_id)
BlendThumbnail * BKE_main_thumbnail_from_buffer(Main *bmain, const uint8_t *rect, const int size[2])
const char * BKE_main_blendfile_path(const Main *bmain)
ID * BKE_main_library_weak_reference_find(Main *bmain, const char *library_filepath, const char *library_id_name)
void BKE_main_unlock(Main *bmain)
static bool are_ids_from_different_mains_matching(Main *bmain_1, ID *id_1, Main *bmain_2, ID *id_2)
static void main_merge_add_id_to_move(Main *bmain_dst, blender::Map< std::string, blender::Vector< ID * > > &id_map_dst, ID *id_src, id::IDRemapper &id_remapper, blender::Vector< ID * > &ids_to_move, const bool is_library, MainMergeReport &reports)
bool BKE_main_is_empty(Main *bmain)
static int main_relations_create_idlink_cb(LibraryIDLinkCallbackData *cb_data)
GSet * BKE_main_gset_create(Main *bmain, GSet *gset)
void BKE_main_relations_free(Main *bmain)
const char * BKE_main_blendfile_path_from_global()
void * MEM_mallocN(size_t len, const char *str)
void * MEM_callocN(size_t len, const char *str)
void MEM_freeN(void *vmemh)
uint64_t get_default_hash(const T &v, const Args &...args)
struct LibraryWeakReference * library_weak_reference
ImBufByteBuffer byte_buffer
friend bool operator==(const LibWeakRefKey &a, const LibWeakRefKey &b)
LibWeakRefKey(const char *lib_path, const char *id_name)
char id_name[MAX_ID_NAME]
LibraryForeachIDCallbackFlag cb_flag
char library_filepath[1024]
char library_id_name[258]
LibraryRuntimeHandle * runtime
bool is_missing_opencolorio_config
MainIDRelationsEntryItem * next
union MainIDRelationsEntryItem::@072362065353355346121131265061232353372304016351 id_pointer
LibraryForeachIDCallbackFlag usage_flag
GHash * relations_from_pointers
BLI_mempool * entry_items_pool
blender::Map< LibWeakRefKey, ID * > map
int num_remapped_libraries
UniqueName_Map * name_map_global
bool has_forward_compatibility_issues
UniqueName_Map * name_map
BlendThumbnail * blen_thumb
bool is_action_slot_to_id_map_dirty
std::shared_ptr< blender::VectorSet< Main * > > split_mains
MainColorspace colorspace
MainIDRelations * relations