82 const int flag =
data->flag;
87 cb_flag = ((cb_flag |
data->cb_flag) & ~
data->cb_flag_clear);
96 const int callback_return =
data->callback(
99 .id_owner =
data->owner_id,
100 .id_self =
data->self_id,
102 .cb_flag = cb_flag});
130 const bool do_replace)
132 const int cb_flag_backup =
data->cb_flag;
134 data->cb_flag = cb_flag;
137 data->cb_flag |= cb_flag;
139 return cb_flag_backup;
165 const int flag =
data->flag;
226 #define CALLBACK_INVOKE_ID(check_id, cb_flag) \
227 BKE_LIB_FOREACHID_PROCESS_ID(&data, check_id, cb_flag)
229 #define CALLBACK_INVOKE(check_id_super, cb_flag) \
230 BKE_LIB_FOREACHID_PROCESS(&data, check_id_super, cb_flag)
245 if (inherit_data ==
NULL) {
268 to_id_entry = to_id_entry->next) {
270 &
data, to_id_entry->id_pointer.to, to_id_entry->usage_flag);
310 if (
data.ids_handled) {
315 #undef CALLBACK_INVOKE_ID
316 #undef CALLBACK_INVOKE
355 const short id_type_owner =
GS(id_owner->
name);
371 switch ((
ID_Type)id_type_owner) {
375 return (
ELEM(id_type_used,
483 const int cb_flag = cb_data->
cb_flag;
494 if (*id_p == iter->
id) {
497 "%s uses %s (refcounted: %d, userone: %d, used_one: %d, used_one_active: %d, "
498 "indirect_usage: %d)\n",
501 (cb_flag & IDWALK_USER) ? 1 : 0,
502 (cb_flag & IDWALK_USER_ONE) ? 1 : 0,
505 (cb_flag & IDWALK_INDIRECT_USAGE) ? 1 : 0);
550 bool is_defined =
false;
554 while (i-- && !is_defined) {
555 ID *id_curr = lb_array[i]->
first;
561 for (; id_curr && !is_defined; id_curr = id_curr->
next) {
603 bool is_defined =
false;
607 while (i-- && !is_defined) {
608 ID *id_curr = lb_array[i]->
first;
614 for (; id_curr && !is_defined; id_curr = id_curr->
next) {
634 const bool do_local_ids,
635 const bool do_linked_ids,
653 if ((
id->
tag & tag) != 0) {
678 bool has_valid_from_users =
false;
680 id_from_item = id_from_item->next) {
681 if ((id_from_item->usage_flag & ignored_usages) != 0 ||
682 (id_from_item->usage_flag & required_usages) == 0) {
686 ID *id_from = id_from_item->id_pointer.from;
691 id_from = type_info_from->
owner_get(bmain, id_from);
695 bmain, tag, do_local_ids, do_linked_ids, id_from, r_num_tagged);
696 if ((id_from->
tag & tag) == 0) {
697 has_valid_from_users =
true;
701 if (!has_valid_from_users) {
704 if (r_num_tagged !=
NULL) {
728 const bool do_local_ids,
729 const bool do_linked_ids,
730 const bool do_tag_recursive,
740 else if (
id->
us == 0) {
742 if (r_num_tagged !=
NULL) {
753 if (!do_tag_recursive) {
769 const int cb_flag = cb_data->
cb_flag;
815 for (
bool do_loop =
true; do_loop;) {
void BKE_animdata_foreach_id(struct AnimData *adt, struct LibraryForeachIDData *data)
struct AnimData * BKE_animdata_from_id(struct ID *id)
void IDP_foreach_property(struct IDProperty *id_property_root, const int type_filter, IDPForeachPropertyCallback callback, void *user_data)
int BKE_idtype_idcode_to_index(const short idcode)
const struct IDTypeInfo * BKE_idtype_get_info_from_id(const struct ID *id)
void id_us_min(struct ID *id)
void id_us_ensure_real(struct ID *id)
void id_us_plus(struct ID *id)
int(* LibraryIDLinkCallback)(LibraryIDLinkCallbackData *cb_data)
@ IDWALK_DO_INTERNAL_RUNTIME_POINTERS
@ IDWALK_IGNORE_EMBEDDED_ID
@ IDWALK_RET_STOP_RECURSION
@ IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE
@ IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE
@ IDWALK_CB_INDIRECT_USAGE
#define BKE_LIB_FOREACHID_PROCESS_ID(_data, _id, _cb_flag)
#define FOREACH_MAIN_ID_END
@ MAINIDRELATIONS_INCLUDE_UI
void BKE_main_relations_create(struct Main *bmain, const short flag)
int set_listbasepointers(struct Main *main, struct ListBase *lb[])
@ MAINIDRELATIONS_ENTRY_TAGS_PROCESSED
void BKE_main_relations_free(struct Main *bmain)
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
struct bNodeTree * ntreeFromID(struct ID *id)
unsigned int BLI_ghashutil_ptrhash(const void *key)
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_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
bool BLI_gset_add(GSet *gs, void *key)
void * BLI_ghash_lookup(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
BLI_LINKSTACK_*** wrapper macros for using a LinkNode to store a stack of pointers,...
#define BLI_LINKSTACK_PUSH(var, ptr)
#define BLI_LINKSTACK_FREE(var)
#define BLI_LINKSTACK_INIT(var)
#define BLI_LINKSTACK_POP(var)
#define LISTBASE_FOREACH(type, var, list)
#define ID_IS_LINKED(_id)
@ IDP_FLAG_OVERRIDABLE_LIBRARY
DEGForeachIDComponentCallback callback
void BKE_library_ID_test_usages(Main *bmain, void *idv, bool *is_used_local, bool *is_used_linked)
bool BKE_lib_query_foreachid_process(LibraryForeachIDData *data, ID **id_pp, int cb_flag)
static void library_foreach_ID_link(Main *bmain, ID *id_owner, ID *id, LibraryIDLinkCallback callback, void *user_data, int flag, LibraryForeachIDData *inherit_data)
void BKE_library_unused_linked_data_set_tag(Main *bmain, const bool do_init_tag)
struct LibraryForeachIDData LibraryForeachIDData
bool BKE_library_ID_is_indirectly_used(Main *bmain, void *idv)
static bool library_ID_is_used(Main *bmain, void *idv, const bool check_linked)
void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback callback, void *user_data, int flag)
static void lib_query_unused_ids_tag_recurse(Main *bmain, const int tag, const bool do_local_ids, const bool do_linked_ids, ID *id, int *r_num_tagged)
int BKE_library_ID_use_ID(ID *id_user, ID *id_used)
int BKE_lib_query_foreachid_process_flags_get(LibraryForeachIDData *data)
int BKE_lib_query_foreachid_process_callback_flag_override(LibraryForeachIDData *data, const int cb_flag, const bool do_replace)
#define CALLBACK_INVOKE_ID(check_id, cb_flag)
void BKE_lib_query_idpropertiesForeachIDLink_callback(IDProperty *id_prop, void *user_data)
static int foreach_libblock_id_users_callback(LibraryIDLinkCallbackData *cb_data)
void BKE_lib_query_unused_ids_tag(Main *bmain, const int tag, const bool do_local_ids, const bool do_linked_ids, const bool do_tag_recursive, int *r_num_tagged)
void BKE_library_update_ID_link_user(ID *id_dst, ID *id_src, const int cb_flag)
struct IDUsersIter IDUsersIter
bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used)
void BKE_library_indirectly_used_data_tag_clear(Main *bmain)
bool BKE_library_foreach_ID_embedded(LibraryForeachIDData *data, ID **id_pp)
bool BKE_library_ID_is_locally_used(Main *bmain, void *idv)
static int foreach_libblock_used_linked_data_tag_clear_cb(LibraryIDLinkCallbackData *cb_data)
IDTypeEmbeddedOwnerGetFunction owner_get
IDTypeForeachIDFunction foreach_id
ListBase * lb_array[INDEX_ID_MAX]
IDOverrideLibrary * override_library
BLI_LINKSTACK_DECLARE(ids_todo, ID *)
LibraryIDLinkCallback callback
struct MainIDRelationsEntryItem * to_ids
struct MainIDRelationsEntryItem * from_ids
struct GHash * relations_from_pointers
struct MainIDRelations * relations