Blender  V3.3
Classes | Macros | Functions | Variables
lib_id.c File Reference
#include <ctype.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "DNA_ID.h"
#include "DNA_anim_types.h"
#include "DNA_collection_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_key_types.h"
#include "DNA_node_types.h"
#include "DNA_workspace_types.h"
#include "BLI_utildefines.h"
#include "BLI_alloca.h"
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
#include "BLI_linklist.h"
#include "BLI_memarena.h"
#include "BLI_string_utils.h"
#include "BLT_translation.h"
#include "BKE_anim_data.h"
#include "BKE_armature.h"
#include "BKE_asset.h"
#include "BKE_bpath.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_gpencil.h"
#include "BKE_idprop.h"
#include "BKE_idtype.h"
#include "BKE_key.h"
#include "BKE_lib_id.h"
#include "BKE_lib_override.h"
#include "BKE_lib_query.h"
#include "BKE_lib_remap.h"
#include "BKE_main.h"
#include "BKE_main_namemap.h"
#include "BKE_node.h"
#include "BKE_rigidbody.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "RNA_access.h"
#include "BLO_read_write.h"
#include "atomic_ops.h"

Go to the source code of this file.

Classes

struct  IDCopyLibManagementData
 

Macros

#define LIB_ID_TYPES_NOCOPY   ID_LI, ID_SCR, ID_WM, ID_WS /* Not supported */
 
#define ID_SORT_STEP_SIZE   512
 

Functions

static bool lib_id_library_local_paths_callback (BPathForeachPathData *bpath_data, char *r_path_dst, const char *path_src)
 
static void lib_id_library_local_paths (Main *bmain, Library *lib, ID *id)
 
static int lib_id_clear_library_data_users_update_cb (LibraryIDLinkCallbackData *cb_data)
 
void BKE_lib_id_clear_library_data (Main *bmain, ID *id, const int flags)
 
void id_lib_extern (ID *id)
 
void id_lib_indirect_weak_link (ID *id)
 
void id_us_ensure_real (ID *id)
 
void id_us_clear_real (ID *id)
 
void id_us_plus_no_lib (ID *id)
 
void id_us_plus (ID *id)
 
void id_us_min (ID *id)
 
void id_fake_user_set (ID *id)
 
void id_fake_user_clear (ID *id)
 
void BKE_id_newptr_and_tag_clear (ID *id)
 
static int lib_id_expand_local_cb (LibraryIDLinkCallbackData *cb_data)
 
void BKE_lib_id_expand_local (Main *bmain, ID *id, const int flags)
 
static void lib_id_copy_ensure_local (Main *bmain, const ID *old_id, ID *new_id, const int flags)
 
void BKE_lib_id_make_local_generic_action_define (struct Main *bmain, struct ID *id, int flags, bool *r_force_local, bool *r_force_copy)
 
void BKE_lib_id_make_local_generic (Main *bmain, ID *id, const int flags)
 
bool BKE_lib_id_make_local (Main *bmain, ID *id, const int flags)
 
static int id_copy_libmanagement_cb (LibraryIDLinkCallbackData *cb_data)
 
bool BKE_id_copy_is_allowed (const ID *id)
 
IDBKE_id_copy_ex (Main *bmain, const ID *id, ID **r_newid, const int flag)
 
IDBKE_id_copy (Main *bmain, const ID *id)
 
IDBKE_id_copy_for_duplicate (Main *bmain, ID *id, const eDupli_ID_Flags duplicate_flags, const int copy_flags)
 
static void id_swap (Main *bmain, ID *id_a, ID *id_b, const bool do_full_id)
 
void BKE_lib_id_swap (Main *bmain, ID *id_a, ID *id_b)
 
void BKE_lib_id_swap_full (Main *bmain, ID *id_a, ID *id_b)
 
bool id_single_user (bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
 
static int libblock_management_us_plus (LibraryIDLinkCallbackData *cb_data)
 
static int libblock_management_us_min (LibraryIDLinkCallbackData *cb_data)
 
void BKE_libblock_management_main_add (Main *bmain, void *idv)
 
void BKE_libblock_management_main_remove (Main *bmain, void *idv)
 
void BKE_libblock_management_usercounts_set (Main *bmain, void *idv)
 
void BKE_libblock_management_usercounts_clear (Main *bmain, void *idv)
 
void BKE_main_id_tag_listbase (ListBase *lb, const int tag, const bool value)
 
void BKE_main_id_tag_idcode (struct Main *mainvar, const short type, const int tag, const bool value)
 
void BKE_main_id_tag_all (struct Main *mainvar, const int tag, const bool value)
 
void BKE_main_id_flag_listbase (ListBase *lb, const int flag, const bool value)
 
void BKE_main_id_flag_all (Main *bmain, const int flag, const bool value)
 
void BKE_main_id_repair_duplicate_names_listbase (Main *bmain, ListBase *lb)
 
void BKE_main_lib_objects_recalc_all (Main *bmain)
 
size_t BKE_libblock_get_alloc_info (short type, const char **name)
 
voidBKE_libblock_alloc_notest (short type)
 
voidBKE_libblock_alloc (Main *bmain, short type, const char *name, const int flag)
 
void BKE_libblock_init_empty (ID *id)
 
void BKE_libblock_runtime_reset_remapping_status (ID *id)
 
void BKE_lib_libblock_session_uuid_ensure (ID *id)
 
void BKE_lib_libblock_session_uuid_renew (ID *id)
 
voidBKE_id_new (Main *bmain, const short type, const char *name)
 
voidBKE_id_new_nomain (const short type, const char *name)
 
void BKE_libblock_copy_ex (Main *bmain, const ID *id, ID **r_newid, const int orig_flag)
 
voidBKE_libblock_copy (Main *bmain, const ID *id)
 
IDBKE_libblock_find_name (struct Main *bmain, const short type, const char *name)
 
struct IDBKE_libblock_find_session_uuid (Main *bmain, const short type, const uint32_t session_uuid)
 
void id_sort_by_name (ListBase *lb, ID *id, ID *id_sorting_hint)
 
bool BKE_id_new_name_validate (struct Main *bmain, ListBase *lb, ID *id, const char *tname, const bool do_linked_data)
 
void BKE_main_id_newptr_and_tag_clear (Main *bmain)
 
static int id_refcount_recompute_callback (LibraryIDLinkCallbackData *cb_data)
 
void BKE_main_id_refcount_recompute (struct Main *bmain, const bool do_linked_only)
 
static void library_make_local_copying_check (ID *id, GSet *loop_tags, MainIDRelations *id_relations, GSet *done_ids)
 
void BKE_library_make_local (Main *bmain, const Library *lib, GHash *old_to_new_ids, const bool untagged_only, const bool set_fake)
 
void BLI_libblock_ensure_unique_name (Main *bmain, const char *name)
 
void BKE_libblock_rename (Main *bmain, ID *id, const char *name)
 
void BKE_id_full_name_get (char name[MAX_ID_FULL_NAME], const ID *id, char separator_char)
 
void BKE_id_full_name_ui_prefix_get (char name[MAX_ID_FULL_NAME_UI], const ID *id, const bool add_lib_hint, char separator_char, int *r_prefix_len)
 
char * BKE_id_to_unique_string_key (const struct ID *id)
 
void BKE_id_tag_set_atomic (ID *id, int tag)
 
void BKE_id_tag_clear_atomic (ID *id, int tag)
 
bool BKE_id_is_in_global_main (ID *id)
 
bool BKE_id_can_be_asset (const ID *id)
 
bool BKE_id_is_editable (const Main *bmain, const ID *id)
 
static int * id_order_get (ID *id)
 
static int id_order_compare (const void *a, const void *b)
 
void BKE_id_ordered_list (ListBase *ordered_lb, const ListBase *lb)
 
void BKE_id_reorder (const ListBase *lb, ID *id, ID *relative, bool after)
 
void BKE_id_blend_write (BlendWriter *writer, ID *id)
 

Variables

static CLG_LogRef LOG = {.identifier = "bke.lib_id"}
 
IDTypeInfo IDType_ID_LINK_PLACEHOLDER
 
static uint global_session_uuid = 0
 

Detailed Description

Contains management of ID's and libraries allocate and free of all library data

Definition in file lib_id.c.

Macro Definition Documentation

◆ ID_SORT_STEP_SIZE

#define ID_SORT_STEP_SIZE   512

◆ LIB_ID_TYPES_NOCOPY

#define LIB_ID_TYPES_NOCOPY   ID_LI, ID_SCR, ID_WM, ID_WS /* Not supported */

Function Documentation

◆ BKE_id_blend_write()

void BKE_id_blend_write ( BlendWriter writer,
ID id 
)

◆ BKE_id_can_be_asset()

bool BKE_id_can_be_asset ( const ID id)

◆ BKE_id_copy()

ID* BKE_id_copy ( Main bmain,
const ID id 
)

Definition at line 667 of file lib_id.c.

References BKE_id_copy_ex(), LIB_ID_COPY_DEFAULT, and NULL.

Referenced by BKE_lib_id_make_local_generic().

◆ BKE_id_copy_ex()

ID* BKE_id_copy_ex ( Main bmain,
const ID id,
ID **  r_newid,
const int  flag 
)

◆ BKE_id_copy_for_duplicate()

ID* BKE_id_copy_for_duplicate ( Main bmain,
ID id,
const eDupli_ID_Flags  duplicate_flags,
const int  copy_flags 
)

◆ BKE_id_copy_is_allowed()

bool BKE_id_copy_is_allowed ( const ID id)

Definition at line 596 of file lib_id.c.

References ELEM, GS, id, ID_TYPE_IS_DEPRECATED, LIB_ID_TYPES_NOCOPY, and ID::name.

◆ BKE_id_full_name_get()

void BKE_id_full_name_get ( char  name[MAX_ID_FULL_NAME],
const ID id,
char  separator_char 
)

Definition at line 1842 of file lib_id.c.

References id, Library::id, ID_IS_LINKED, ID::lib, and ID::name.

Referenced by BKE_id_full_name_ui_prefix_get().

◆ BKE_id_full_name_ui_prefix_get()

void BKE_id_full_name_ui_prefix_get ( char  name[MAX_ID_FULL_NAME_UI],
const ID id,
const bool  add_lib_hint,
char  separator_char,
int *  r_prefix_len 
)

◆ BKE_id_is_editable()

bool BKE_id_is_editable ( const Main bmain,
const ID id 
)

Definition at line 1915 of file lib_id.c.

References BKE_lib_override_library_is_system_defined(), and ID_IS_LINKED.

◆ BKE_id_is_in_global_main()

bool BKE_id_is_in_global_main ( struct ID id)

Check that given ID pointer actually is in G_MAIN. Main intended use is for debug asserts in places we cannot easily get rid of #G_Main.

Definition at line 1902 of file lib_id.c.

References BLI_findindex(), G_MAIN, GS, id, ID::name, NULL, and which_libbase().

Referenced by bpy_bmesh_to_mesh(), pygpu_offscreen_draw_view3d(), and pyrna_struct_keyframe_insert().

◆ BKE_id_new()

void* BKE_id_new ( struct Main bmain,
short  type,
const char *  name 
)

◆ BKE_id_new_name_validate()

bool BKE_id_new_name_validate ( struct Main bmain,
ListBase lb,
ID id,
const char *  tname,
const bool  do_linked_data 
)

◆ BKE_id_new_nomain()

void* BKE_id_new_nomain ( short  type,
const char *  name 
)

◆ BKE_id_newptr_and_tag_clear()

void BKE_id_newptr_and_tag_clear ( ID id)

◆ BKE_id_ordered_list()

void BKE_id_ordered_list ( ListBase ordered_lb,
const ListBase lb 
)

◆ BKE_id_reorder()

void BKE_id_reorder ( const ListBase lb,
ID id,
ID relative,
bool  after 
)

Definition at line 1972 of file lib_id.c.

References BLI_listbase_count(), id_order_get(), LISTBASE_FOREACH, and order.

◆ BKE_id_tag_clear_atomic()

void BKE_id_tag_clear_atomic ( ID id,
int  tag 
)

Definition at line 1897 of file lib_id.c.

References atomic_fetch_and_and_int32(), id, and ID::tag.

◆ BKE_id_tag_set_atomic()

void BKE_id_tag_set_atomic ( ID id,
int  tag 
)

Definition at line 1892 of file lib_id.c.

References atomic_fetch_and_or_int32(), id, and ID::tag.

◆ BKE_id_to_unique_string_key()

char* BKE_id_to_unique_string_key ( const struct ID id)

Generate a concatenation of ID name (including two-chars type code) and its lib name, if any.

Returns
A unique allocated string key for any ID in the whole Main database.

Definition at line 1879 of file lib_id.c.

References BLI_sprintfN(), BLI_strdup(), id, Library::id, ID_IS_LINKED, ID::lib, and ID::name.

Referenced by gpencil_strokes_copypastebuf_colors_material_to_name_create(), and gpencil_strokes_copypastebuf_colors_name_to_material_create().

◆ BKE_lib_id_clear_library_data()

void BKE_lib_id_clear_library_data ( struct Main bmain,
struct ID id,
int  flags 
)

◆ BKE_lib_id_expand_local()

void BKE_lib_id_expand_local ( struct Main bmain,
struct ID id,
int  flags 
)

Expand ID usages of given id as 'extern' (and no more indirect) linked data. Used by ID copy/make_local functions.

Definition at line 427 of file lib_id.c.

References BKE_library_foreach_ID_link(), IDWALK_READONLY, lib_id_expand_local_cb(), and POINTER_FROM_INT.

Referenced by BKE_lib_id_make_local_generic(), BKE_library_make_local(), brush_make_local(), and lib_id_copy_ensure_local().

◆ BKE_lib_id_make_local()

bool BKE_lib_id_make_local ( struct Main bmain,
struct ID id,
int  flags 
)

Calls the appropriate make_local method for the block, unless test is set.

Note
Always set ID.newid pointer in case it gets duplicated.
Parameters
flagsSpecial flag used when making a whole library's content local, it needs specific handling.
Returns
true is the ID has successfully been made local.

Definition at line 533 of file lib_id.c.

References BKE_idtype_get_info_from_id(), BKE_lib_id_make_local_generic(), BLI_assert, BLI_assert_msg, IDTypeInfo::flags, id, IDTYPE_FLAGS_NO_LIBLINKING, LIB_ID_MAKELOCAL_FULL_LIBRARY, LIB_TAG_INDIRECT, IDTypeInfo::make_local, NULL, and ID::tag.

Referenced by BKE_blendfile_append(), BKE_library_make_local(), brush_make_local(), id_local_fn(), and template_id_cb().

◆ BKE_lib_id_make_local_generic()

void BKE_lib_id_make_local_generic ( struct Main bmain,
struct ID id,
int  flags 
)

◆ BKE_lib_id_make_local_generic_action_define()

void BKE_lib_id_make_local_generic_action_define ( struct Main bmain,
struct ID id,
int  flags,
bool r_force_local,
bool r_force_copy 
)

Helper to decide whether given id can be directly made local, or needs to be copied. r_force_local and r_force_copy cannot be true together. But both can be false, in case no action should be performed.

Note
low-level helper to de-duplicate logic between BKE_lib_id_make_local_generic and the specific corner-cases implementations needed for objects and brushes.

Definition at line 444 of file lib_id.c.

References BKE_library_ID_test_usages(), BLI_assert, LIB_ID_MAKELOCAL_FORCE_COPY, LIB_ID_MAKELOCAL_FORCE_LOCAL, and LIB_ID_MAKELOCAL_FULL_LIBRARY.

Referenced by BKE_lib_id_make_local_generic(), and brush_make_local().

◆ BKE_lib_id_swap()

void BKE_lib_id_swap ( struct Main bmain,
struct ID id_a,
struct ID id_b 
)

Does a mere memory swap over the whole IDs data (including type-specific memory).

Note
Most internal ID data itself is not swapped (only IDProperties are).
Parameters
bmainMay be NULL, in which case there will be no remapping of internal pointers to itself.

Definition at line 752 of file lib_id.c.

References id_swap().

Referenced by brush_undo_preserve(), lib_override_id_swap(), and palette_undo_preserve().

◆ BKE_lib_id_swap_full()

void BKE_lib_id_swap_full ( struct Main bmain,
struct ID id_a,
struct ID id_b 
)

Does a mere memory swap over the whole IDs data (including type-specific memory).

Note
All internal ID data itself is also swapped.
Parameters
bmainMay be NULL, in which case there will be no remapping of internal pointers to itself.

Definition at line 757 of file lib_id.c.

References id_swap().

Referenced by read_libblock_undo_restore_at_old_address().

◆ BKE_lib_libblock_session_uuid_ensure()

void BKE_lib_libblock_session_uuid_ensure ( struct ID id)

Generate a session-wise uuid for the given id.

Note
"session-wise" here means while editing a given .blend file. Once a new .blend file is loaded or created, undo history is cleared/reset, and so is the uuid counter.

Definition at line 1140 of file lib_id.c.

References atomic_add_and_fetch_uint32(), BLI_assert, global_session_uuid, id, LIB_TAG_TEMP_MAIN, MAIN_ID_SESSION_UUID_UNSET, ID::session_uuid, ID::tag, and UNLIKELY.

Referenced by BKE_lib_libblock_session_uuid_renew(), BKE_libblock_alloc(), BKE_libblock_management_main_add(), create_placeholder(), direct_link_id_common(), and versions_gpencil_add_main().

◆ BKE_lib_libblock_session_uuid_renew()

void BKE_lib_libblock_session_uuid_renew ( struct ID id)

Re-generate a new session-wise uuid for the given id.

Warning
This has a few very specific use-cases, no other usage is expected currently:
  • To handle UI-related data-blocks that are kept across new file reading, when we do keep existing UI.
  • For IDs that are made local without needing any copying.

Definition at line 1153 of file lib_id.c.

References BKE_lib_libblock_session_uuid_ensure(), and MAIN_ID_SESSION_UUID_UNSET.

Referenced by BKE_lib_id_clear_library_data(), and setup_app_data().

◆ BKE_libblock_alloc()

void* BKE_libblock_alloc ( struct Main bmain,
short  type,
const char *  name,
int  flag 
)

◆ BKE_libblock_alloc_notest()

void* BKE_libblock_alloc_notest ( short  type)

Allocates and returns memory of the right size for the specified block type, initialized to zero.

Definition at line 1039 of file lib_id.c.

References BKE_libblock_get_alloc_info(), BLI_assert_msg, MEM_callocN, NULL, size(), and type.

Referenced by BKE_libblock_alloc(), create_placeholder(), and blender::deg::IDNode::init_copy_on_write().

◆ BKE_libblock_copy()

void* BKE_libblock_copy ( Main bmain,
const ID id 
)

Definition at line 1286 of file lib_id.c.

References BKE_libblock_copy_ex().

◆ BKE_libblock_copy_ex()

void BKE_libblock_copy_ex ( Main bmain,
const ID id,
ID **  r_newid,
const int  orig_flag 
)

◆ BKE_libblock_find_name()

ID* BKE_libblock_find_name ( struct Main bmain,
const short  type,
const char *  name 
)

◆ BKE_libblock_find_session_uuid()

struct ID* BKE_libblock_find_session_uuid ( Main bmain,
const short  type,
const uint32_t  session_uuid 
)

◆ BKE_libblock_get_alloc_info()

size_t BKE_libblock_get_alloc_info ( short  type,
const char **  name 
)

Get allocation size of a given data-block type and optionally allocation name.

Definition at line 1022 of file lib_id.c.

References BKE_idtype_get_info_from_idcode(), IDTypeInfo::name, NULL, IDTypeInfo::struct_size, and type.

Referenced by BKE_id_copy_ex(), BKE_libblock_alloc_notest(), and BKE_libblock_copy_ex().

◆ BKE_libblock_init_empty()

void BKE_libblock_init_empty ( struct ID id)

Initialize an ID of given type, such that it has valid 'empty' data. ID is assumed to be just calloc'ed.

Definition at line 1115 of file lib_id.c.

References BKE_idtype_get_info_from_id(), BLI_assert_msg, IDTypeInfo::init_data, and NULL.

Referenced by BKE_id_new(), BKE_id_new_nomain(), BKE_mesh_new_nomain(), create_placeholder(), and ntreeAddTree().

◆ BKE_libblock_management_main_add()

void BKE_libblock_management_main_add ( struct Main bmain,
void idv 
)

◆ BKE_libblock_management_main_remove()

void BKE_libblock_management_main_remove ( struct Main bmain,
void idv 
)

Remove a data-block from given main (set it to 'NO_MAIN' status).

Definition at line 859 of file lib_id.c.

References BKE_main_lock(), BKE_main_namemap_remove_name(), BKE_main_unlock(), BLI_assert, BLI_remlink(), GS, id, Main::is_memfile_undo_written, LIB_TAG_NO_MAIN, ID::name, NULL, ID::tag, and which_libbase().

◆ BKE_libblock_management_usercounts_clear()

void BKE_libblock_management_usercounts_clear ( Main bmain,
void idv 
)

◆ BKE_libblock_management_usercounts_set()

void BKE_libblock_management_usercounts_set ( Main bmain,
void idv 
)

◆ BKE_libblock_rename()

void BKE_libblock_rename ( struct Main bmain,
struct ID id,
const char *  name 
)

Sets the name of a block to name, suitably adjusted for uniqueness.

Definition at line 1832 of file lib_id.c.

References BKE_id_new_name_validate(), BKE_main_namemap_remove_name(), BLI_assert, GS, id, ID_IS_LINKED, Main::is_memfile_undo_written, ID::name, and which_libbase().

Referenced by blender::bke::tests::TEST(), and DocumentImporter::write_node().

◆ BKE_libblock_runtime_reset_remapping_status()

void BKE_libblock_runtime_reset_remapping_status ( struct ID id)

Reset the runtime counters used by ID remapping.

Definition at line 1129 of file lib_id.c.

Referenced by libblock_remap_foreach_idpair_cb(), and libblock_remap_reset_remapping_status_callback().

◆ BKE_library_make_local()

void BKE_library_make_local ( Main bmain,
const Library lib,
GHash old_to_new_ids,
const bool  untagged_only,
const bool  set_fake 
)

◆ BKE_main_id_flag_all()

void BKE_main_id_flag_all ( struct Main bmain,
int  flag,
bool  value 
)

Clear or set given flags for all ids in bmain (persistent flags).

Definition at line 957 of file lib_id.c.

References Freestyle::a, BKE_main_id_flag_listbase(), IDCopyLibManagementData::flag, INDEX_ID_MAX, and set_listbasepointers().

◆ BKE_main_id_flag_listbase()

void BKE_main_id_flag_listbase ( struct ListBase lb,
int  flag,
bool  value 
)

Clear or set given flags for all ids in listbase (persistent flags).

Definition at line 941 of file lib_id.c.

References ListBase::first, IDCopyLibManagementData::flag, id, ID::next, and ID::tag.

Referenced by BKE_main_id_flag_all(), and id_search_cb_objects_from_scene().

◆ BKE_main_id_newptr_and_tag_clear()

void BKE_main_id_newptr_and_tag_clear ( struct Main bmain)

◆ BKE_main_id_refcount_recompute()

void BKE_main_id_refcount_recompute ( struct Main bmain,
const bool  do_linked_only 
)

◆ BKE_main_id_repair_duplicate_names_listbase()

void BKE_main_id_repair_duplicate_names_listbase ( struct Main bmain,
struct ListBase lb 
)

Only for repairing files via versioning, avoid for general use.

Definition at line 967 of file lib_id.c.

References BKE_id_new_name_validate(), BLI_gset_add(), BLI_gset_free(), BLI_gset_str_new_ex(), id, ID_IS_LINKED, LISTBASE_FOREACH, MEM_freeN, MEM_mallocN, and NULL.

Referenced by blo_do_versions_280(), blo_do_versions_290(), and blo_do_versions_300().

◆ BKE_main_id_tag_all()

void BKE_main_id_tag_all ( struct Main mainvar,
int  tag,
bool  value 
)

◆ BKE_main_id_tag_idcode()

void BKE_main_id_tag_idcode ( struct Main mainvar,
short  type,
int  tag,
bool  value 
)

Clear or set given tags for all ids of given type in bmain (runtime tags).

Note
Affect whole Main database.

Definition at line 920 of file lib_id.c.

References BKE_main_id_tag_listbase(), type, and which_libbase().

Referenced by bake_objects_check(), bake_targets_init_image_textures(), BKE_blendfile_library_relocate(), id_delete_tag(), and sound_update_animation_flags_exec().

◆ BKE_main_id_tag_listbase()

void BKE_main_id_tag_listbase ( struct ListBase lb,
int  tag,
bool  value 
)

Clear or set given tags for all ids in listbase (runtime tags).

Definition at line 904 of file lib_id.c.

References ListBase::first, id, ID::next, and ID::tag.

Referenced by BKE_collection_object_cyclic_check(), BKE_main_id_tag_all(), BKE_main_id_tag_idcode(), BKE_workspace_id_tag_all_visible(), clean_viewport_memory(), object_delete_exec(), and previews_ensure_exec().

◆ BKE_main_lib_objects_recalc_all()

void BKE_main_lib_objects_recalc_all ( Main bmain)

◆ BLI_libblock_ensure_unique_name()

void BLI_libblock_ensure_unique_name ( struct Main bmain,
const char *  name 
)

Use after setting the ID's name When name exists: call 'new_id'

Definition at line 1813 of file lib_id.c.

References BKE_id_new_name_validate(), BLI_findstring(), GS, ID_IS_LINKED, Main::is_memfile_undo_written, ID::name, NULL, and which_libbase().

Referenced by BLO_update_defaults_startup_blend(), do_versions_rename_id(), and namebutton_fn().

◆ id_copy_libmanagement_cb()

static int id_copy_libmanagement_cb ( LibraryIDLinkCallbackData cb_data)
static

◆ id_fake_user_clear()

void id_fake_user_clear ( ID id)

◆ id_fake_user_set()

void id_fake_user_set ( ID id)

◆ id_lib_extern()

void id_lib_extern ( ID id)

◆ id_lib_indirect_weak_link()

void id_lib_indirect_weak_link ( ID id)

◆ id_order_compare()

static int id_order_compare ( const void a,
const void b 
)
static

Definition at line 1933 of file lib_id.c.

References Freestyle::a, usdtokens::b(), id_order_get(), and ID::name.

Referenced by BKE_id_ordered_list().

◆ id_order_get()

static int* id_order_get ( ID id)
static

Definition at line 1922 of file lib_id.c.

References GS, id, ID_WS, ID::name, and NULL.

Referenced by BKE_id_ordered_list(), BKE_id_reorder(), and id_order_compare().

◆ id_refcount_recompute_callback()

static int id_refcount_recompute_callback ( LibraryIDLinkCallbackData cb_data)
static

◆ id_single_user()

bool id_single_user ( struct bContext C,
struct ID id,
struct PointerRNA ptr,
struct PropertyRNA prop 
)

◆ id_sort_by_name()

void id_sort_by_name ( struct ListBase lb,
struct ID id,
struct ID id_sorting_hint 
)

Sort given id into given lb list, using case-insensitive comparison of the id names.

Note
All other IDs beside given one are assumed already properly sorted in the list.
Parameters
id_sorting_hintIgnored if NULL. Otherwise, used to check if we can insert id immediately before or after that pointer. It must always be into given lb list.

Definition at line 1318 of file lib_id.c.

References BLI_addhead(), BLI_addtail(), BLI_assert, BLI_findindex(), BLI_insertlinkafter(), BLI_insertlinkbefore(), BLI_remlink(), BLI_strcasecmp(), ELEM, ListBase::first, id, ID_IS_LINKED, ID_SORT_STEP_SIZE, ListBase::last, ID::lib, ID::name, ID::next, NULL, and ID::prev.

Referenced by blender::bke::tests::add_id_in_library(), BKE_blendfile_write_partial(), BKE_id_new_name_validate(), blendfile_library_relocate_remap(), create_placeholder(), expand_doit_library(), link_named_part(), sort_linked_ids(), and blender::bke::tests::TEST().

◆ id_swap()

static void id_swap ( Main bmain,
ID id_a,
ID id_b,
const bool  do_full_id 
)
static

Does a mere memory swap over the whole IDs data (including type-specific memory).

Note
Most internal ID data itself is not swapped (only IDProperties are).

Definition at line 715 of file lib_id.c.

References BKE_idtype_get_info_from_id(), BKE_libblock_relink_ex(), BLI_assert, GS, ID_REMAP_SKIP_NEVER_NULL_USAGE, ID::name, NULL, ID::properties, ID::recalc, and IDTypeInfo::struct_size.

Referenced by BKE_lib_id_swap(), and BKE_lib_id_swap_full().

◆ id_us_clear_real()

void id_us_clear_real ( ID id)

◆ id_us_ensure_real()

void id_us_ensure_real ( struct ID id)

◆ id_us_min()

void id_us_min ( ID id)

Definition at line 313 of file lib_id.c.

References CLOG_ERROR, Library::filepath_abs, GS, id, ID_FAKE_USERS, ID_TYPE_IS_DEPRECATED, id_us_ensure_real(), ID::lib, LIB_TAG_EXTRAUSER, LOG, ID::name, ID::tag, and ID::us.

Referenced by action_create_new(), action_to_animato(), blender::io::usd::USDMaterialReader::add_material(), ANIM_remove_empty_action_from_animdata(), animdata_copy_id_action(), animrecord_check_state(), blender::bke::id::remapper::IDRemapper::apply(), apply_objects_internal(), blender::io::alembic::utils::assign_materials(), background_image_remove_exec(), BCAnimation::BCAnimation(), BKE_animdata_free(), BKE_animdata_set_action(), BKE_animdata_transfer_by_basepath(), BKE_blendfile_library_relocate(), BKE_brush_add_gpencil(), BKE_freestyle_config_free(), BKE_freestyle_lineset_delete(), BKE_gpencil_brush_material_set(), BKE_gpencil_brush_preset_set(), BKE_gpencil_object_material_new(), BKE_gpencil_palette_ensure(), BKE_id_copy_for_duplicate(), BKE_id_free_us(), BKE_id_material_assign(), BKE_id_material_clear(), BKE_id_material_pop(), BKE_id_material_resize(), BKE_lib_override_library_clear(), BKE_lib_override_library_init(), BKE_lib_override_library_main_proxy_convert(), BKE_lib_override_library_proxy_convert(), BKE_library_update_ID_link_user(), BKE_mesh_assign_object(), BKE_mesh_new_from_object_to_bmain(), BKE_mesh_nomain_to_mesh(), BKE_mesh_to_curve(), BKE_mesh_to_pointcloud(), BKE_nla_action_pushdown(), BKE_nla_tweakmode_exit(), BKE_nlastrip_free(), BKE_object_add_only_object(), BKE_object_material_from_eval_data(), BKE_object_material_resize(), BKE_object_material_slot_remove(), BKE_paint_brush_set(), BKE_paint_curve_set(), BKE_paint_init(), BKE_paint_palette_set(), BKE_paint_toolslots_brush_update_ex(), BKE_paint_toolslots_brush_validate(), BKE_pointcloud_to_mesh(), BKE_pose_channel_free_ex(), BKE_scene_add(), BKE_scene_duplicate(), BKE_text_add(), BKE_text_load_ex(), BKE_texture_mtex_add_id(), BKE_workspace_layout_remove(), BLO_update_defaults_startup_blend(), brush_add_exec(), brush_add_gpencil_exec(), brush_generic_tool_set(), brush_undo_preserve_cb(), cachefile_open_exec(), collection_add(), collection_child_remove(), collection_instance_fix_recursive(), collection_object_remove(), con_unlink_refs_cb(), copy_particle_systems_to_object(), DocumentImporter::create_instance_node(), do_version_layers_to_collections(), do_versions_ipos_to_animato(), drop_world_exec(), duplibase_for_convert(), ED_mesh_join_objects_exec(), empty_drop_named_image_invoke(), eyedropper_add_palette_color(), font_open_exec(), foreach_libblock_remap_callback_apply(), FRS_paste_active_lineset(), geometry_node_tree_copy_assign_exec(), blender::io::obj::get_or_create_material(), Freestyle::BlenderStrokeRenderer::GetStrokeShader(), gpencil_data_add_exec(), gpencil_data_unlink_exec(), gpencil_stroke_separate_exec(), id_fake_user_clear(), id_single_user(), IDP_AssignID(), IDP_FreePropertyContent_ex(), image_new_exec(), image_open_exec(), blender::io::usd::import_startjob(), import_startjob(), ipo_to_animato(), lib_override_library_create_from(), lib_override_library_create_post_process(), libblock_management_us_min(), make_links_data_exec(), make_object_duplilist_real(), modifier_free_data_id_us_cb(), new_material_exec(), blender::ed::space_node::new_node_tree_exec(), new_particle_settings_exec(), new_texture_exec(), new_world_exec(), nlaedit_apply_scale_exec(), nlaedit_make_single_user_exec(), blender::ed::space_node::node_id_remap_cb(), nodeRemoveNode(), object_convert_exec(), object_data_convert_curve_to_mesh(), object_material_assign(), object_remove_particle_system(), object_unlink_data_exec(), open_exec(), paste_mtex_copybuf(), poselib_init_new(), poselib_unlink_exec(), restrictbutton_id_user_toggle(), scene_foreach_toolsettings_id_pointer_process(), separate_exec(), seq_convert_callback(), SEQ_effect_text_font_unload(), seq_sequence_free_ex(), set_current_brush_texture(), set_current_linestyle_texture(), set_current_particle_texture(), shaderfx_free_data_id_us_cb(), single_obdata_users(), single_object_users_collection(), socket_id_user_decrement(), solve_camera_freejob(), template_id_cb(), blender::io::stl::STLMeshHelper::to_mesh(), unlink_material_fn(), unlink_texture_fn(), unlink_world_fn(), MeshImporter::write_geometry(), and DocumentImporter::writeMaterial().

◆ id_us_plus()

void id_us_plus ( ID id)

Definition at line 305 of file lib_id.c.

References id_lib_extern(), and id_us_plus_no_lib().

Referenced by blender::io::usd::USDGeomReader::add_cache_modifier(), blender::io::alembic::AbcObjectReader::addCacheModifier(), apply_objects_internal(), BKE_animdata_copy(), BKE_animdata_merge_copy(), BKE_animdata_set_action(), BKE_camera_background_image_copy(), BKE_gpencil_brush_material_set(), BKE_id_material_append(), BKE_id_material_assign(), BKE_id_materials_copy(), BKE_image_load_exists_ex(), BKE_lib_override_library_copy(), BKE_lib_override_library_init(), BKE_library_update_ID_link_user(), BKE_linestyle_alpha_modifier_copy(), BKE_linestyle_color_modifier_copy(), BKE_linestyle_thickness_modifier_copy(), BKE_mesh_assign_object(), BKE_movieclip_file_add_exists_ex(), BKE_nla_tweakmode_enter(), BKE_nlastrip_copy(), BKE_nlastrip_new(), BKE_object_add_for_data(), BKE_object_copy_particlesystem(), BKE_object_material_from_eval_data(), BKE_paint_brush_set(), BKE_paint_copy(), BKE_paint_curve_set(), BKE_paint_palette_set(), BKE_paint_toolslots_brush_update_ex(), BKE_pose_channel_copy_data(), BKE_pose_copy_data_ex(), BKE_sound_new_file_exists_ex(), BKE_vfont_load_exists_ex(), BKE_view_layer_copy_data(), BKE_workspace_layout_add(), collection_child_add(), collection_drop_exec(), collection_instance_add_exec(), collection_instance_exec(), collection_object_add(), con_fix_copied_refs_cb(), copy_lineset(), MeshImporter::create_mesh_object(), drop_world_exec(), ED_mesh_join_objects_exec(), ED_rigidbody_constraint_add(), empty_drop_named_image_invoke(), foreach_libblock_make_usercounts_callback(), FRS_paste_active_lineset(), Freestyle::BlenderStrokeRenderer::GenerateStrokeMesh(), gpencil_modifier_copy_data_id_us_cb(), id_copy_libmanagement_cb(), id_fake_user_set(), IDP_AssignID(), IDP_CopyID(), IDP_New(), blender::nodes::node_composite_movieclip_cc::init(), blender::nodes::node_composite_moviedistortion_cc::init(), blender::nodes::node_composite_planetrackdeform_cc::init(), blender::nodes::node_composite_stabilize2d_cc::init(), blender::nodes::node_composite_trackpos_cc::init(), blender::nodes::node_composite_switchview_cc::init_switch_view(), libblock_management_us_plus(), loose_data_instantiate_collection_process(), loose_data_instantiate_obdata_process(), make_links_data_exec(), make_local_all__instance_indirect_unused(), mesh_separate_material_assign_mat_nr(), modifier_copy_data_id_us_cb(), blender::ed::space_node::node_add_collection_exec(), blender::ed::space_node::node_add_group_exec(), blender::ed::space_node::node_add_mask_exec(), blender::ed::space_node::node_add_object_exec(), blender::nodes::node_composite_keyingscreen_cc::node_composit_init_keyingscreen(), blender::nodes::node_composite_image_cc::node_composit_init_rlayers(), blender::bke::node_copy_with_mapping(), blender::ed::space_node::node_id_remap_cb(), node_init(), blender::nodes::node_composite_cryptomatte_cc::node_init_api_cryptomatte(), blender::ed::space_node::node_link_item_apply(), node_socket_copy_default_value(), object_add_or_copy_particle_system(), object_convert_exec(), object_data_convert_curve_to_mesh(), object_gpencil_add_exec(), object_material_assign(), paint_toolslots_init(), paste_mtex_copybuf(), blender::io::usd::USDXformReader::read_object_data(), restrictbutton_id_user_toggle(), seq_dupli(), SEQ_effect_text_font_load(), set_current_brush_texture(), set_current_linestyle_texture(), set_current_particle_texture(), blender::io::alembic::AbcObjectReader::setupObjectTransform(), shaderfx_copy_data_id_us_cb(), socket_id_user_increment(), solve_camera_freejob(), template_id_cb(), tracking_plane_tracks_copy(), tracking_tracks_copy(), txt_add_object(), WM_drag_free_imported_drag_ID(), and WM_operator_drop_load_path().

◆ id_us_plus_no_lib()

void id_us_plus_no_lib ( struct ID id)

◆ lib_id_clear_library_data_users_update_cb()

static int lib_id_clear_library_data_users_update_cb ( LibraryIDLinkCallbackData cb_data)
static

◆ lib_id_copy_ensure_local()

static void lib_id_copy_ensure_local ( Main bmain,
const ID old_id,
ID new_id,
const int  flags 
)
static

Ensure new (copied) ID is fully made local.

Definition at line 436 of file lib_id.c.

References BKE_lib_id_expand_local(), ID_IS_LINKED, ID::lib, and lib_id_library_local_paths().

Referenced by BKE_id_copy_ex().

◆ lib_id_expand_local_cb()

static int lib_id_expand_local_cb ( LibraryIDLinkCallbackData cb_data)
static

◆ lib_id_library_local_paths()

static void lib_id_library_local_paths ( Main bmain,
Library lib,
ID id 
)
static

This has to be called from each make_local_* func, we could call from BKE_lib_id_make_local() but then the make local functions would not be self contained. Also note that the id must have a library - campbell

Definition at line 154 of file lib_id.c.

References BKE_bpath_foreach_path_id(), BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE, BKE_main_blendfile_path(), id, lib, and lib_id_library_local_paths_callback().

Referenced by BKE_lib_id_clear_library_data(), and lib_id_copy_ensure_local().

◆ lib_id_library_local_paths_callback()

static bool lib_id_library_local_paths_callback ( BPathForeachPathData bpath_data,
char *  r_path_dst,
const char *  path_src 
)
static

Rewrites a relative path to be relative to the main file - unless the path is absolute, in which case it is not altered.

Definition at line 117 of file lib_id.c.

References BLI_path_abs(), BLI_path_is_rel(), BLI_path_normalize(), BLI_path_rel(), BLI_strncpy(), CLOG_ERROR, data, FILE_MAX, FILE_MAXDIR, FILE_MAXFILE, LOG, and BPathForeachPathData::user_data.

Referenced by lib_id_library_local_paths().

◆ libblock_management_us_min()

static int libblock_management_us_min ( LibraryIDLinkCallbackData cb_data)
static

◆ libblock_management_us_plus()

static int libblock_management_us_plus ( LibraryIDLinkCallbackData cb_data)
static

◆ library_make_local_copying_check()

static void library_make_local_copying_check ( ID id,
GSet loop_tags,
MainIDRelations id_relations,
GSet done_ids 
)
static

Variable Documentation

◆ global_session_uuid

uint global_session_uuid = 0
static

Definition at line 1138 of file lib_id.c.

Referenced by BKE_lib_libblock_session_uuid_ensure().

◆ IDType_ID_LINK_PLACEHOLDER

IDTypeInfo IDType_ID_LINK_PLACEHOLDER
Initial value:
= {
.id_code = ID_LINK_PLACEHOLDER,
.id_filter = 0,
.main_listbase_index = INDEX_ID_NULL,
.struct_size = sizeof(ID),
.name = "LinkPlaceholder",
.name_plural = "link_placeholders",
.translation_context = BLT_I18NCONTEXT_ID_ID,
.asset_type_info = NULL,
.copy_data = NULL,
.free_data = NULL,
.make_local = NULL,
.foreach_id = NULL,
.foreach_cache = NULL,
.foreach_path = NULL,
.owner_get = NULL,
.blend_write = NULL,
.blend_read_data = NULL,
.blend_read_lib = NULL,
.blend_read_expand = NULL,
.blend_read_undo_preserve = NULL,
.lib_override_apply_post = NULL,
}
@ IDTYPE_FLAGS_NO_COPY
Definition: BKE_idtype.h:30
@ IDTYPE_FLAGS_NO_LIBLINKING
Definition: BKE_idtype.h:32
#define BLT_I18NCONTEXT_ID_ID
@ INDEX_ID_NULL
Definition: DNA_ID.h:1057
struct ID ID
#define ID_LINK_PLACEHOLDER
Definition: DNA_ID_enums.h:88
static void init_data(ModifierData *md)

Empty shell mostly, but needed for read code.

Definition at line 77 of file lib_id.c.

Referenced by id_type_init().

◆ LOG

CLG_LogRef LOG = {.identifier = "bke.lib_id"}
static

Definition at line 75 of file lib_id.c.

Referenced by id_us_ensure_real(), id_us_min(), and lib_id_library_local_paths_callback().