82 for (
id =
static_cast<ID *
>(lb->
first);
id !=
nullptr;
id = id_next) {
83 id_next =
static_cast<ID *
>(
id->next);
90# define CASE_ID_INDEX(id_index) \
92 BKE_id_free_ex(&bmain, id, free_flag, false); \
112 CASE_ID_INDEX(INDEX_ID_SIM);
172 bmain.
lock =
nullptr;
186 "'.blend' relative \"//\" must not be used in Main!");
217 if (lib_1 && lib_2) {
247 if (!id_1->
lib && !id_2->
lib) {
251 if (id_1->
lib && id_2->
lib) {
252 if (id_1->
lib == id_2->
lib) {
286 const bool is_library,
289 const bool is_id_src_linked(id_src->
lib);
290 bool is_id_src_from_bmain_dst =
false;
291 if (is_id_src_linked) {
298 is_id_src_from_bmain_dst = !id_src_lib_dst.
is_empty() && !id_src_lib_dst[0];
300 std::cout << id_src->
name <<
" is linked from dst Main: " << is_id_src_from_bmain_dst <<
"\n";
303 if (is_id_src_from_bmain_dst) {
309 "ID '%s' defined in source Main as linked from destination Main (file '%s') not "
310 "found in given destination Main",
313 id_remapper.
add(id_src,
nullptr);
317 ids_to_move.
append(id_src);
323 Main *bmain_src = *r_bmain_src;
326 ID *id_iter_dst, *id_iter_src;
352 const bool is_library =
GS(id_iter_src->
name) ==
ID_LI;
355 is_library ?
reinterpret_cast<Library *
>(id_iter_src)->runtime.filepath_abs :
363 bmain_dst, id_map_dst, id_iter_src, id_remapper, ids_to_move, is_library, reports);
367 bool src_has_match_in_dst =
false;
368 for (
ID *id_iter_dst : ids_dst) {
372 if (!src_has_match_in_dst) {
374 id_remapper_libraries.
add(id_iter_src, id_iter_dst);
378 id_remapper.
add(id_iter_src, id_iter_dst);
381 src_has_match_in_dst =
true;
388 if (!src_has_match_in_dst) {
390 bmain_dst, id_map_dst, id_iter_src, id_remapper, ids_to_move, is_library, reports);
399 if (bmain_src->
filepath[0] !=
'\0') {
404 if (bmain_dst->
filepath[0] !=
'\0') {
421 id_remapper_libraries,
424 for (
ID *id_iter_src : ids_to_move) {
437 "Merged %d IDs from '%s' Main into '%s' Main; %d IDs and %d Libraries already existed as "
438 "part of the destination Main, and %d IDs missing from destination Main, were freed "
439 "together with the source Main",
454 *r_bmain_src =
nullptr;
494 const int cb_flag = cb_data->
cb_flag;
512 to_id_entry->
next = (*entry_p)->to_ids;
514 to_id_entry->
session_uid = (*id_pointer !=
nullptr) ? (*id_pointer)->session_uid :
517 (*entry_p)->to_ids = to_id_entry;
521 if (*id_pointer !=
nullptr) {
526 (*entry_p)->
session_uid = (*id_pointer)->session_uid;
529 BLI_assert((*entry_p)->session_uid == (*id_pointer)->session_uid);
533 from_id_entry->
next = (*entry_p)->from_ids;
537 (*entry_p)->from_ids = from_id_entry;
571 BLI_assert((*entry_p)->session_uid == id->session_uid);
617 if (gset ==
nullptr) {
636 STRNCPY(this->filepath, lib_path);
642 return STREQ(a.filepath,
b.filepath) &&
STREQ(a.id_name,
b.id_name);
658 auto *library_weak_reference_mapping = MEM_new<MainLibraryWeakReferenceMap>(__func__);
662 ID *id_iter =
static_cast<ID *
>(lb->
first);
663 if (id_iter ==
nullptr) {
677 library_weak_reference_mapping->map.add(key, id_iter);
683 return library_weak_reference_mapping;
689 MEM_delete(library_weak_reference_mapping);
694 const char *library_filepath,
695 const char *library_id_name)
703 const char *library_filepath,
704 const char *library_id_name,
715 library_weak_reference_mapping->
map.
add_new(key, new_id);
723 const char *library_filepath,
724 const char *library_id_name,
745 const char *library_filepath,
746 const char *library_id_name,
755 library_weak_reference_mapping->
map.
remove(key);
771 data->
width = size[0];
772 data->height = size[1];
773 memcpy(data->rect, rect, data_size -
sizeof(*data));
795 data->width = img->
x;
796 data->height = img->
y;
808 ImBuf *img =
nullptr;
810 if (!data && bmain) {
816 (
const uint8_t *)data->rect,
nullptr,
uint(data->width),
uint(data->height), 4);
870 return &(bmain->
ipo);
878 return &(bmain->
fonts);
880 return &(bmain->
texts);
908 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)
void BKE_library_foreach_ID_link(Main *bmain, ID *id, blender::FunctionRef< LibraryIDLinkCallback > callback, void *user_data, int flag)
@ ID_REMAP_DO_LIBRARY_POINTERS
void BKE_libblock_relink_multiple(Main *bmain, const blender::Span< ID * > ids, eIDRemapType remap_type, blender::bke::id::IDRemapper &id_remapper, int remap_flags)
#define FOREACH_MAIN_ID_END
#define FOREACH_MAIN_LISTBASE_ID_END
@ 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) ATTR_NONNULL()
bool BKE_main_namemap_validate(Main *bmain) ATTR_NONNULL()
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
BLI_INLINE void BLI_listbase_clear(struct 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)
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)
#define STRNCPY(dst, 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_rect_from_float(ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
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
void add_new(const Key &key, const Value &value)
bool remove(const Key &key)
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)
local_group_size(16, 16) .push_constant(Type b
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
struct ImBuf * IMB_allocFromBuffer(const uint8_t *, const float *, unsigned int, unsigned int, unsigned int)
ID * BKE_main_library_weak_reference_search_item(MainLibraryWeakReferenceMap *library_weak_reference_mapping, const char *library_filepath, const char *library_id_name)
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_destroy(Main &bmain)
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)
int set_listbasepointers(Main *bmain, ListBase *lb[])
void BKE_main_thumbnail_create(Main *bmain)
ImBuf * BKE_main_thumbnail_to_imbuf(Main *bmain, BlendThumbnail *data)
void BKE_main_init(Main &bmain)
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)
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_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
uint64_t get_default_hash(const T &v)
unsigned __int64 uint64_t
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]
char library_filepath[1024]
struct Library_Runtime runtime
union MainIDRelationsEntryItem::@41 id_pointer
MainIDRelationsEntryItem * next
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
MainIDRelations * relations