Blender  V3.3
Macros | Typedefs | Enumerations | Functions
BKE_lib_id.h File Reference
#include "BLI_compiler_attrs.h"
#include "BLI_utildefines.h"

Go to the source code of this file.

Macros

#define MAIN_ID_SESSION_UUID_UNSET   0
 
#define MAX_ID_FULL_NAME   (64 + 64 + 3 + 1) /* 64 is MAX_ID_NAME - 2 */
 
#define MAX_ID_FULL_NAME_UI   (MAX_ID_FULL_NAME + 3) /* Adds 'keycode' two letters at beginning. */
 
#define IS_TAGGED(_id)   ((_id) && (((ID *)_id)->tag & LIB_TAG_DOIT))
 

Typedefs

typedef enum eLibIDDuplicateFlags eLibIDDuplicateFlags
 

Enumerations

enum  {
  LIB_ID_CREATE_NO_MAIN = 1 << 0 , LIB_ID_CREATE_NO_USER_REFCOUNT = 1 << 1 , LIB_ID_CREATE_NO_ALLOCATE = 1 << 2 , LIB_ID_CREATE_NO_DEG_TAG = 1 << 8 ,
  LIB_ID_CREATE_LOCAL = 1 << 9 , LIB_ID_COPY_SET_COPIED_ON_WRITE = 1 << 10 , LIB_ID_COPY_NO_PREVIEW = 1 << 17 , LIB_ID_COPY_CACHES = 1 << 18 ,
  LIB_ID_COPY_NO_ANIMDATA = 1 << 19 , LIB_ID_COPY_CD_REFERENCE = 1 << 20 , LIB_ID_COPY_NO_LIB_OVERRIDE = 1 << 21 , LIB_ID_COPY_NO_LIB_OVERRIDE_LOCAL_DATA_FLAG = 1 << 22 ,
  LIB_ID_COPY_ACTIONS = 1 << 24 , LIB_ID_COPY_KEEP_LIB = 1 << 25 , LIB_ID_COPY_SHAPEKEY = 1 << 26 , LIB_ID_COPY_NODETREE_LOCALIZE = 1 << 27 ,
  LIB_ID_COPY_RIGID_BODY_NO_COLLECTION_HANDLING = 1 << 28 , LIB_ID_COPY_DEFAULT = LIB_ID_COPY_SHAPEKEY , LIB_ID_CREATE_LOCALIZE , LIB_ID_COPY_LOCALIZE
}
 
enum  eLibIDDuplicateFlags { LIB_ID_DUPLICATE_IS_SUBPROCESS = 1 << 0 , LIB_ID_DUPLICATE_IS_ROOT_ID = 1 << 1 }
 
enum  {
  LIB_ID_FREE_NO_MAIN = 1 << 0 , LIB_ID_FREE_NO_USER_REFCOUNT = 1 << 1 , LIB_ID_FREE_NOT_ALLOCATED = 1 << 2 , LIB_ID_FREE_NO_DEG_TAG = 1 << 8 ,
  LIB_ID_FREE_NO_UI_USER = 1 << 9 , LIB_ID_FREE_NO_NAMEMAP_REMOVE = 1 << 10
}
 
enum  { LIB_ID_MAKELOCAL_FULL_LIBRARY = 1 << 0 , LIB_ID_MAKELOCAL_FORCE_LOCAL = 1 << 1 , LIB_ID_MAKELOCAL_FORCE_COPY = 1 << 2 , LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR = 1 << 3 }
 

Functions

size_t BKE_libblock_get_alloc_info (short type, const char **name)
 
voidBKE_libblock_alloc_notest (short type) ATTR_WARN_UNUSED_RESULT
 
voidBKE_libblock_alloc (struct Main *bmain, short type, const char *name, int flag) ATTR_WARN_UNUSED_RESULT
 
void BKE_libblock_init_empty (struct ID *id) ATTR_NONNULL(1)
 
void BKE_libblock_runtime_reset_remapping_status (struct ID *id) ATTR_NONNULL(1)
 
void BKE_lib_libblock_session_uuid_ensure (struct ID *id)
 
void BKE_lib_libblock_session_uuid_renew (struct ID *id)
 
voidBKE_id_new (struct Main *bmain, short type, const char *name)
 
voidBKE_id_new_nomain (short type, const char *name)
 
void BKE_libblock_copy_ex (struct Main *bmain, const struct ID *id, struct ID **r_newid, int orig_flag)
 
voidBKE_libblock_copy (struct Main *bmain, const struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
 
void BKE_libblock_rename (struct Main *bmain, struct ID *id, const char *name) ATTR_NONNULL()
 
void BLI_libblock_ensure_unique_name (struct Main *bmain, const char *name) ATTR_NONNULL()
 
struct IDBKE_libblock_find_name (struct Main *bmain, short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
 
struct IDBKE_libblock_find_session_uuid (struct Main *bmain, short type, uint32_t session_uuid)
 
void BKE_libblock_free_datablock (struct ID *id, int flag) ATTR_NONNULL()
 
void BKE_libblock_free_data (struct ID *id, bool do_id_user) ATTR_NONNULL()
 
void BKE_libblock_free_data_py (struct ID *id)
 
void BKE_id_free_ex (struct Main *bmain, void *idv, int flag, bool use_flag_from_idtag)
 
void BKE_id_free (struct Main *bmain, void *idv)
 
void BKE_id_free_us (struct Main *bmain, void *idv) ATTR_NONNULL()
 
void BKE_id_delete (struct Main *bmain, void *idv) ATTR_NONNULL()
 
size_t BKE_id_multi_tagged_delete (struct Main *bmain) ATTR_NONNULL()
 
void BKE_libblock_management_main_add (struct Main *bmain, void *idv)
 
void BKE_libblock_management_main_remove (struct Main *bmain, void *idv)
 
void BKE_libblock_management_usercounts_set (struct Main *bmain, void *idv)
 
void BKE_libblock_management_usercounts_clear (struct Main *bmain, void *idv)
 
void id_lib_extern (struct ID *id)
 
void id_lib_indirect_weak_link (struct ID *id)
 
void id_us_ensure_real (struct ID *id)
 
void id_us_clear_real (struct ID *id)
 
void id_us_plus_no_lib (struct ID *id)
 
void id_us_plus (struct ID *id)
 
void id_us_min (struct ID *id)
 
void id_fake_user_set (struct ID *id)
 
void id_fake_user_clear (struct ID *id)
 
void BKE_id_newptr_and_tag_clear (struct ID *id)
 
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 (struct Main *bmain, struct ID *id, int flags)
 
bool BKE_lib_id_make_local (struct Main *bmain, struct ID *id, int flags)
 
bool id_single_user (struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop)
 
bool BKE_id_copy_is_allowed (const struct ID *id)
 
struct IDBKE_id_copy_ex (struct Main *bmain, const struct ID *id, struct ID **r_newid, int flag)
 
struct IDBKE_id_copy (struct Main *bmain, const struct ID *id)
 
struct IDBKE_id_copy_for_duplicate (struct Main *bmain, struct ID *id, uint duplicate_flags, int copy_flags)
 
void BKE_lib_id_swap (struct Main *bmain, struct ID *id_a, struct ID *id_b)
 
void BKE_lib_id_swap_full (struct Main *bmain, struct ID *id_a, struct ID *id_b)
 
void id_sort_by_name (struct ListBase *lb, struct ID *id, struct ID *id_sorting_hint)
 
void BKE_lib_id_expand_local (struct Main *bmain, struct ID *id, int flags)
 
bool BKE_id_new_name_validate (struct Main *bmain, struct ListBase *lb, struct ID *id, const char *name, bool do_linked_data) ATTR_NONNULL(1
 
bool void BKE_lib_id_clear_library_data (struct Main *bmain, struct ID *id, int flags)
 
void BKE_main_id_tag_idcode (struct Main *mainvar, short type, int tag, bool value)
 
void BKE_main_id_tag_listbase (struct ListBase *lb, int tag, bool value)
 
void BKE_main_id_tag_all (struct Main *mainvar, int tag, bool value)
 
void BKE_main_id_flag_listbase (struct ListBase *lb, int flag, bool value)
 
void BKE_main_id_flag_all (struct Main *bmain, int flag, bool value)
 
void BKE_main_id_newptr_and_tag_clear (struct Main *bmain)
 
void BKE_main_id_refcount_recompute (struct Main *bmain, bool do_linked_only)
 
void BKE_main_lib_objects_recalc_all (struct Main *bmain)
 
void BKE_main_id_repair_duplicate_names_listbase (struct Main *bmain, struct ListBase *lb)
 
void BKE_id_full_name_get (char name[MAX_ID_FULL_NAME], const struct ID *id, char separator_char)
 
void BKE_id_full_name_ui_prefix_get (char name[MAX_ID_FULL_NAME_UI], const struct ID *id, bool add_lib_hint, char separator_char, int *r_prefix_len)
 
char * BKE_id_to_unique_string_key (const struct ID *id)
 
void BKE_library_make_local (struct Main *bmain, const struct Library *lib, struct GHash *old_to_new_ids, bool untagged_only, bool set_fake)
 
void BKE_id_tag_set_atomic (struct ID *id, int tag)
 
void BKE_id_tag_clear_atomic (struct ID *id, int tag)
 
bool BKE_id_is_in_global_main (struct ID *id)
 
bool BKE_id_can_be_asset (const struct ID *id)
 
bool BKE_id_is_editable (const struct Main *bmain, const struct ID *id)
 
void BKE_id_ordered_list (struct ListBase *ordered_lb, const struct ListBase *lb)
 
void BKE_id_reorder (const struct ListBase *lb, struct ID *id, struct ID *relative, bool after)
 
void BKE_id_blend_write (struct BlendWriter *writer, struct ID *id)
 
void BKE_id_eval_properties_copy (struct ID *id_cow, struct ID *id)
 

Detailed Description

API to manage data-blocks inside of Blender's Main data-base, or as independent runtime-only data.

Note
BKE_lib_ files are for operations over data-blocks themselves, although they might alter Main as well (when creating/renaming/deleting an ID e.g.).

Names

Warning
Descriptions below is ideal goal, current status of naming does not yet fully follow it (this is WIP).
Note
External code should typically not use BKE_lib_libblock_ functions, except in some specific cases requiring advanced (and potentially dangerous) handling.

Definition in file BKE_lib_id.h.

Macro Definition Documentation

◆ IS_TAGGED

#define IS_TAGGED (   _id)    ((_id) && (((ID *)_id)->tag & LIB_TAG_DOIT))

Definition at line 639 of file BKE_lib_id.h.

◆ MAIN_ID_SESSION_UUID_UNSET

#define MAIN_ID_SESSION_UUID_UNSET   0

When an ID's uuid is of that value, it is unset/invalid (e.g. for runtime IDs, etc.).

Definition at line 82 of file BKE_lib_id.h.

◆ MAX_ID_FULL_NAME

#define MAX_ID_FULL_NAME   (64 + 64 + 3 + 1) /* 64 is MAX_ID_NAME - 2 */

Definition at line 550 of file BKE_lib_id.h.

◆ MAX_ID_FULL_NAME_UI

#define MAX_ID_FULL_NAME_UI   (MAX_ID_FULL_NAME + 3) /* Adds 'keycode' two letters at beginning. */

Definition at line 551 of file BKE_lib_id.h.

Typedef Documentation

◆ eLibIDDuplicateFlags

Duplicate (a.k.a. deep copy) common processing options. See also eDupli_ID_Flags for options controlling what kind of IDs to duplicate.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

New ID creation/copying options.

Enumerator
LIB_ID_CREATE_NO_MAIN 

Create datablock outside of any main database - similar to 'localize' functions of materials etc.

LIB_ID_CREATE_NO_USER_REFCOUNT 

Do not affect user refcount of datablocks used by new one (which also gets zero usercount then). Implies LIB_ID_CREATE_NO_MAIN.

LIB_ID_CREATE_NO_ALLOCATE 

Assume given 'newid' already points to allocated memory for whole datablock (ID + data) - USE WITH CAUTION! Implies LIB_ID_CREATE_NO_MAIN.

LIB_ID_CREATE_NO_DEG_TAG 

Do not tag new ID for update in depsgraph.

LIB_ID_CREATE_LOCAL 

Very similar to LIB_ID_CREATE_NO_MAIN, and should never be used with it (typically combined with LIB_ID_CREATE_LOCALIZE or LIB_ID_COPY_LOCALIZE in fact). It ensures that IDs created with it will get the LIB_TAG_LOCALIZED tag, and uses some specific code in some copy cases (mostly for node trees).

LIB_ID_COPY_SET_COPIED_ON_WRITE 

Create for the depsgraph, when set LIB_TAG_COPIED_ON_WRITE must be set. Internally this is used to share some pointers instead of duplicating them.

LIB_ID_COPY_NO_PREVIEW 

Object only, needed by make_local code. Do not copy preview data, when supported.

LIB_ID_COPY_CACHES 

Copy runtime data caches.

LIB_ID_COPY_NO_ANIMDATA 

Don't copy id->adt, used by ID data-block localization routines.

LIB_ID_COPY_CD_REFERENCE 

Mesh: Reference CD data layers instead of doing real copy - USE WITH CAUTION!

LIB_ID_COPY_NO_LIB_OVERRIDE 

Do not copy id->override_library, used by ID data-block override routines.

LIB_ID_COPY_NO_LIB_OVERRIDE_LOCAL_DATA_FLAG 

When copying local sub-data (like constraints or modifiers), do not set their "library override local data" flag.

LIB_ID_COPY_ACTIONS 

EXCEPTION! Deep-copy actions used by animation-data of copied ID.

LIB_ID_COPY_KEEP_LIB 

Keep the library pointer when copying data-block outside of bmain.

LIB_ID_COPY_SHAPEKEY 

EXCEPTION! Deep-copy shape-keys used by copied obdata ID.

LIB_ID_COPY_NODETREE_LOCALIZE 

EXCEPTION! Specific deep-copy of node trees used e.g. for rendering purposes.

LIB_ID_COPY_RIGID_BODY_NO_COLLECTION_HANDLING 

EXCEPTION! Specific handling of RB objects regarding collections differs depending whether we duplicate scene/collections, or objects.

LIB_ID_COPY_DEFAULT 

Shape-keys are not real ID's, more like local data to geometry IDs.

LIB_ID_CREATE_LOCALIZE 

Create a local, outside of bmain, data-block to work on.

LIB_ID_COPY_LOCALIZE 

Generate a local copy, outside of bmain, to work on (used by COW e.g.).

Definition at line 118 of file BKE_lib_id.h.

◆ anonymous enum

anonymous enum

New freeing logic options.

Enumerator
LIB_ID_FREE_NO_MAIN 

Do not try to remove freed ID from given Main (passed Main may be NULL).

LIB_ID_FREE_NO_USER_REFCOUNT 

Do not affect user refcount of datablocks used by freed one. Implies LIB_ID_FREE_NO_MAIN.

LIB_ID_FREE_NOT_ALLOCATED 

Assume freed ID datablock memory is managed elsewhere, do not free it (still calls relevant ID type's freeing function though) - USE WITH CAUTION! Implies LIB_ID_FREE_NO_MAIN.

LIB_ID_FREE_NO_DEG_TAG 

Do not tag freed ID for update in depsgraph.

LIB_ID_FREE_NO_UI_USER 

Do not attempt to remove freed ID from UI data/notifiers/...

LIB_ID_FREE_NO_NAMEMAP_REMOVE 

Do not remove freed ID's name from a potential runtime namemap.

Definition at line 237 of file BKE_lib_id.h.

◆ anonymous enum

anonymous enum

Flags to control make local code behavior.

Enumerator
LIB_ID_MAKELOCAL_FULL_LIBRARY 

Making that ID local is part of making local a whole library.

LIB_ID_MAKELOCAL_FORCE_LOCAL 

In case caller code already knows this ID should be made local without copying.

LIB_ID_MAKELOCAL_FORCE_COPY 

In case caller code already knows this ID should be made local using copying.

LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR 

Clear asset data (in case the ID can actually be made local, in copy case asset data is never copied over).

Definition at line 358 of file BKE_lib_id.h.

◆ eLibIDDuplicateFlags

Duplicate (a.k.a. deep copy) common processing options. See also eDupli_ID_Flags for options controlling what kind of IDs to duplicate.

Enumerator
LIB_ID_DUPLICATE_IS_SUBPROCESS 

This call to a duplicate function is part of another call for some parent ID. Therefore, this sub-process should not clear newid pointers, nor handle remapping itself. NOTE: In some cases (like Object one), the duplicate function may be called on the root ID with this flag set, as remapping and/or other similar tasks need to be handled by the caller.

LIB_ID_DUPLICATE_IS_ROOT_ID 

This call is performed on a 'root' ID, and should therefore perform some decisions regarding sub-IDs (dependencies), check for linked vs. locale data, etc.

Definition at line 219 of file BKE_lib_id.h.

Function Documentation

◆ BKE_id_blend_write()

void BKE_id_blend_write ( struct BlendWriter writer,
struct ID id 
)

◆ BKE_id_can_be_asset()

bool BKE_id_can_be_asset ( const struct ID id)

◆ BKE_id_copy()

struct ID* BKE_id_copy ( struct Main bmain,
const struct ID id 
)

◆ BKE_id_copy_ex()

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

Generic entry point for copying a data-block (new API).

Note
Copy is generally only affecting the given data-block (no ID used by copied one will be affected, besides user-count).

There are exceptions though:

  • Embedded IDs (root node trees and master collections) are always copied with their owner.
  • If LIB_ID_COPY_ACTIONS is defined, actions used by anim-data will be duplicated.
  • If LIB_ID_COPY_SHAPEKEY is defined, shape-keys will be duplicated.
  • If LIB_ID_CREATE_LOCAL is defined, root node trees will be deep-duplicated recursively.
Note
User-count of new copy is always set to 1.
Parameters
bmainMain database, may be NULL only if LIB_ID_CREATE_NO_MAIN is specified.
idSource data-block.
r_newidPointer to new (copied) ID pointer, may be NULL. Used to allow copying into already allocated memory.
flagSet of copy options, see DNA_ID.h enum for details (leave to zero for default, full copy).
Returns
NULL when copying that ID type is not supported, the new copy otherwise.

Referenced by bc_get_mesh_copy(), BKE_animdata_copy(), BKE_curves_copy_for_eval(), BKE_displist_make_curveTypes(), BKE_lattice_modifiers_calc(), BKE_lib_override_library_update(), BKE_mesh_copy_for_eval(), BKE_mesh_create_derived_for_modifier(), BKE_nlastrip_copy(), BKE_pointcloud_copy_for_eval(), BKE_volume_copy_for_eval(), clip_start_prefetch_job(), curve_copy_data(), curve_from_curve_object(), curve_from_font_object(), deformVerts(), do_hair_dynamics(), duplicate_ids(), flip_pose(), geometry_node_tree_copy_assign_exec(), get_quick_mesh(), blender::compositor::MaskOperation::init_execution(), lattice_copy_data(), lib_override_library_create_from(), light_copy_data(), linestyle_copy_data(), material_copy_data(), mesh_copy_data(), mesh_new_from_mesh(), MOD_deform_mesh_eval_get(), modifyMesh(), new_material_exec(), new_world_exec(), normalEditModifier_do(), ntreeCopyTree_ex(), ntreeLocalize(), object_for_curve_to_mesh_create(), particle_settings_localize(), preview_get_localized_world(), psys_thread_context_init_distribute(), remap_hair_emitter(), scene_copy_data(), seq_render_mask(), simulation_copy_data(), single_mat_users(), single_obdata_users(), single_object_users_collection(), texture_copy_data(), undomesh_from_editmesh(), and world_copy_data().

◆ BKE_id_copy_for_duplicate()

struct ID* BKE_id_copy_for_duplicate ( struct Main bmain,
struct ID id,
uint  duplicate_flags,
int  copy_flags 
)

Invoke the appropriate copy method for the block and return the new id as result.

Unlike BKE_id_copy, it does set the ID.newid pointer of the given id to the copied one.

It is designed as a basic common helper for the higher-level 'duplicate' operations (aka 'deep copy' of data-blocks and some of their dependency ones), see e.g. BKE_object_duplicate.

Currently, it only handles the given ID, and their shape keys and actions if any, according to the given duplicate_flags.

Parameters
duplicate_flagsis of type eDupli_ID_Flags, see UserDef.dupflag. Currently only USER_DUP_LINKED_ID and USER_DUP_ACT have an effect here.
copy_flagsflags passed to BKE_id_copy_ex.

Referenced by BKE_object_duplicate(), BKE_scene_duplicate(), and collection_duplicate_recursive().

◆ BKE_id_copy_is_allowed()

bool BKE_id_copy_is_allowed ( const struct ID id)

Test whether given id can be copied or not.

Referenced by template_ID().

◆ BKE_id_delete()

void BKE_id_delete ( struct Main bmain,
void idv 
)

◆ BKE_id_eval_properties_copy()

void BKE_id_eval_properties_copy ( struct ID id_cow,
struct ID id 
)

◆ BKE_id_free()

void BKE_id_free ( struct Main bmain,
void idv 
)

Complete ID freeing, should be usable in most cases (even for out-of-Main IDs).

See BKE_id_free_ex description for full details.

Parameters
bmainMain database containing the freed ID, can be NULL in case it's a temp ID outside of any Main.
idvPointer to ID to be freed.

Definition at line 172 of file lib_id_delete.c.

References BKE_id_free_ex().

Referenced by bake(), BKE_blendfile_library_relocate(), BKE_crazyspace_build_sculpt(), BKE_crazyspace_get_first_deform_matrices_editbmesh(), BKE_fluid_modifier_freeEffector(), BKE_fluid_modifier_freeFlow(), BKE_id_free_us(), BKE_image_merge(), BKE_lib_override_library_resync(), BKE_mesh_create_derived_for_modifier(), BKE_mesh_eval_geometry(), BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(), BKE_mesh_nomain_to_mesh(), BKE_mesh_runtime_clear_cache(), BKE_object_free_caches(), BKE_object_to_curve_clear(), BKE_object_to_mesh_clear(), BKE_sculpt_get_first_deform_matrices(), BKE_workspace_layout_remove(), BKE_workspace_remove(), bpy_bmesh_from_object(), C_BVHTree_FromObject(), canvas_copyMesh(), MeshComponent::clear(), PointCloudComponent::clear(), CurveComponent::clear(), VolumeComponent::clear(), cloth_build_springs(), construct_param_handle_subsurfed(), deformMatrices(), deformVerts(), deformVertsEM(), distribute_particles_on_dm(), do_hair_dynamics(), do_multires_bake(), dynamicPaint_brushMeshCalculateVelocity(), dynamicPaint_Modifier_apply(), dynamicPaint_Modifier_free_runtime(), dynamicPaint_paintMesh(), ED_workspace_delete(), editbmesh_calc_modifiers(), EEVEE_shaders_free(), final_skin(), blender::io::alembic::ABCGenericMeshWriter::free_export_mesh(), blender::io::usd::USDGenericMeshWriter::free_export_mesh(), blender::io::alembic::ABCMetaballWriter::free_export_mesh(), blender::io::usd::USDMetaballWriter::free_export_mesh(), free_hair(), freeData(), geometry_extract_apply(), gpencil_do_frame_fill(), blender::compositor::MaskOperation::init_execution(), knifeproject_poly_from_object(), lib_override_library_main_resync_on_library_indirect_level(), lineart_geometry_object_load(), mesh_calc_modifiers(), mesh_new_from_curve_type_object(), mesh_wrapper_ensure_subdivision(), mirrorModifier__doMirror(), MOD_deform_mesh_eval_get(), modifier_apply_shape(), modifyMesh(), multiresModifier_reshapeFromDeformModifier(), blender::nodes::node_geo_deform_curves_on_surface_cc::node_geo_exec(), blender::ed::space_node::node_group_ungroup(), object_for_curve_to_mesh_free(), GeometryExporter::operator()(), paint_mask_slice_exec(), poselib_blend_free(), psys_thread_context_init_distribute(), quadriflow_start_job(), RE_bake_normal_world_to_tangent(), RE_bake_pixels_populate_from_objects(), read_libblock(), remap_hair_emitter(), remesh_symmetry_bisect(), remesh_symmetry_mirror(), sculpt_gesture_trim_geometry_free(), sculpt_gesture_trim_normals_update(), seq_render_mask(), blender::bke::tests::TEST(), voxel_remesh_exec(), and blender::eevee::MaterialModule::~MaterialModule().

◆ BKE_id_free_ex()

void BKE_id_free_ex ( struct Main bmain,
void idv,
int  flag,
bool  use_flag_from_idtag 
)

Complete ID freeing, extended version for corner cases. Can override default (and safe!) freeing process, to gain some speed up.

At that point, given id is assumed to not be used by any other data-block already (might not be actually true, in case e.g. several inter-related IDs get freed together...). However, they might still be using (referencing) other IDs, this code takes care of it if LIB_TAG_NO_USER_REFCOUNT is not defined.

Parameters
bmainMain database containing the freed ID, can be NULL in case it's a temp ID outside of any Main.
idvPointer to ID to be freed.
flagSet of LIB_ID_FREE_... flags controlling/overriding usual freeing process, 0 to get default safe behavior.
use_flag_from_idtagStill use freeing info flags from given ID datablock, even if some overriding ones are passed in flag parameter.

Definition at line 82 of file lib_id_delete.c.

References BKE_id_free_ex(), BKE_id_remapper_add(), BKE_id_remapper_create(), BKE_id_remapper_free(), BKE_key_from_id(), BKE_libblock_free_data(), BKE_libblock_free_data_py(), BKE_libblock_free_datablock(), BKE_libblock_relink_ex(), BKE_main_lock(), BKE_main_namemap_remove_name(), BKE_main_unlock(), BLI_assert, BLI_remlink(), DEG_id_type_tag(), free_notifier_reference_cb, GS, id, Key::id, ID_REMAP_SKIP_USER_CLEAR, Main::is_locked_for_linking, LIB_ID_FREE_NO_DEG_TAG, LIB_ID_FREE_NO_MAIN, LIB_ID_FREE_NO_NAMEMAP_REMOVE, LIB_ID_FREE_NO_UI_USER, LIB_ID_FREE_NO_USER_REFCOUNT, LIB_ID_FREE_NOT_ALLOCATED, LIB_TAG_NO_MAIN, LIB_TAG_NO_USER_REFCOUNT, LIB_TAG_NOT_ALLOCATED, MEM_freeN, ID::name, NULL, remap_editor_id_reference_cb, ID::tag, type, and which_libbase().

Referenced by BKE_id_free(), BKE_id_free_ex(), BKE_lib_override_library_operations_store_finalize(), BKE_lib_override_library_operations_store_start(), BKE_lib_override_library_update(), BKE_main_free(), ED_mesh_join_objects_exec(), and id_delete().

◆ BKE_id_free_us()

void BKE_id_free_us ( struct Main bmain,
void idv 
)

◆ BKE_id_full_name_get()

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

Generate full name of the data-block (without ID code, but with library if any).

Note
Result is unique to a given ID type in a given Main database.
Parameters
nameAn allocated string of minimal length MAX_ID_FULL_NAME, will be filled with generated string.
separator_charCharacter to use for separating name and library name. Can be 0 to use default (' ').

Referenced by SEQ_effect_text_font_load().

◆ BKE_id_full_name_ui_prefix_get()

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

Generate full name of the data-block (without ID code, but with library if any), with a 2 to 3 character prefix prepended indicating whether it comes from a library, is overriding, has a fake or no user, etc.

Note
Result is unique to a given ID type in a given Main database.
Parameters
nameAn allocated string of minimal length MAX_ID_FULL_NAME_UI, will be filled with generated string.
separator_charCharacter to use for separating name and library name. Can be 0 to use default (' ').
r_prefix_lenThe length of the prefix added.

Referenced by add_collection_search_item(), id_search_add(), and ui_rna_collection_search_update_fn().

◆ BKE_id_is_editable()

bool BKE_id_is_editable ( const struct Main bmain,
const struct ID id 
)

Check if that ID can be considered as editable from a high-level (editor) perspective.

NOTE: This used to be done with a check on whether ID was linked or not, but now with system overrides this is not enough anymore.

NOTE: Execution of this function can be somewhat expensive currently. If this becomes an issue, we should either cache that status info also in virtual override IDs, or address the long-standing TODO of getting an efficient 'owner_id' access for all embedded ID types.

Referenced by collection_flag_exec(), copy_particle_systems_to_object(), createTransObject(), createTransSculpt(), datastack_drop_init(), depthdropper_init(), depthdropper_poll(), do_outliner_item_posemode_toggle(), draw_setting_widget(), ED_editors_init(), ED_object_posemode_enter(), ED_object_posemode_enter_ex(), ED_operator_node_editable(), ED_operator_object_active_editable_ex(), ED_operator_posemode_local(), ED_operator_scene_editable(), edbm_separate_exec(), edit_modifier_poll_generic(), edit_shaderfx_poll_generic(), blender::ed::geometry::geometry_attributes_poll(), gpencil_edit_modifier_poll_generic(), gpencil_vertex_group_poll(), gpencil_vertex_group_weight_poll(), has_poselib_pose_data_for_editing_poll(), initFlyInfo(), initWalkInfo(), insert_keyframe(), lib_id_fake_user_toggle_exec(), make_links_data_exec(), make_links_scene_exec(), object_convert_exec(), blender::ed::curves::object_has_editable_curves(), object_origin_set_exec(), object_transform_to_mouse_exec(), outliner_color_tag_set_exec(), parent_drop_set_parents(), poselib_add_poll(), poselib_keytag_pose(), posemode_exec(), scene_drop_invoke(), shade_smooth_exec(), single_mat_users(), single_obdata_users(), single_object_action_users(), single_objectdata_action_users(), special_aftertrans_update__sculpt(), text_edit_poll(), text_region_edit_poll(), text_space_edit_poll(), view3d_camera_to_view_poll(), WIDGETGROUP_camera_poll(), and WIDGETGROUP_camera_view_poll().

◆ 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_multi_tagged_delete()

size_t BKE_id_multi_tagged_delete ( struct Main bmain)

Properly delete all IDs tagged with LIB_TAG_DOIT, in given bmain database.

This is more efficient than calling BKE_id_delete repetitively on a large set of IDs (several times faster when deleting most of the IDs at once).

Warning
Considered experimental for now, seems to be working OK but this is risky code in a complicated area.
Returns
Number of deleted datablocks.

Definition at line 377 of file lib_id_delete.c.

References id_delete().

Referenced by BKE_blendfile_append(), BKE_blendfile_library_relocate(), BKE_lib_override_library_delete(), bpy_batch_remove(), bpy_orphans_purge(), lib_override_library_resync(), object_delete_exec(), outliner_delete_exec(), outliner_id_delete_invoke(), outliner_id_operation_exec(), outliner_lib_operation_exec(), and outliner_orphans_purge_exec().

◆ 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,
struct ListBase lb,
struct ID id,
const char *  name,
bool  do_linked_data 
)

Ensures given ID has a unique name in given listbase.

Only for local IDs (linked ones already have a unique ID in their library).

Parameters
do_linked_dataif true, also ensure a unique name in case the given id is linked (otherwise, just ensure that it is properly sorted).
Returns
true if a new name had to be created.

Referenced by blender::bke::tests::change_name(), main_namemap_validate_and_fix(), and versions_gpencil_add_main().

◆ 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 ( struct ID id)

◆ BKE_id_ordered_list()

void BKE_id_ordered_list ( struct ListBase ordered_lb,
const struct ListBase lb 
)

Returns ordered list of data-blocks for display in the UI. Result is list of LinkData of IDs that must be freed.

Referenced by ED_workspace_delete(), space_workspace_cycle_invoke(), and template_ID_tabs().

◆ BKE_id_reorder()

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

Reorder ID in the list, before or after the "relative" ID.

Referenced by workspace_append_activate_exec(), workspace_reorder_to_back_exec(), and workspace_reorder_to_front_exec().

◆ BKE_id_tag_clear_atomic()

void BKE_id_tag_clear_atomic ( struct 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 ( struct 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()

bool 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 ( struct Main bmain,
const struct ID id 
)

Used everywhere in blenkernel.

◆ BKE_libblock_copy_ex()

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

◆ BKE_libblock_find_name()

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

◆ BKE_libblock_find_session_uuid()

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

◆ BKE_libblock_free_data()

void BKE_libblock_free_data ( struct ID id,
bool  do_id_user 
)

◆ BKE_libblock_free_data_py()

void BKE_libblock_free_data_py ( struct ID id)

In most cases BKE_id_free_ex handles this, when lower level functions are called directly this function will need to be called too, if Python has access to the data.

ID data-blocks such as Material.nodetree are not stored in Main.

Definition at line 386 of file lib_id_delete.c.

References BPY_DECREF_RNA_INVALIDATE(), BPY_id_release(), id, ID::py_instance, and UNUSED_VARS.

Referenced by BKE_id_free_ex(), blender::deg::deg_free_copy_on_write_datablock(), ntreeFreeEmbeddedTree(), scene_free_data(), and wm_close_and_free_all().

◆ BKE_libblock_free_datablock()

void BKE_libblock_free_datablock ( struct ID id,
int  flag 
)

◆ 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 ( struct Main bmain,
void idv 
)

◆ BKE_libblock_management_usercounts_set()

void BKE_libblock_management_usercounts_set ( struct 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 ( struct Main bmain,
const struct Library lib,
struct GHash old_to_new_ids,
bool  untagged_only,
bool  set_fake 
)

Make linked data-blocks local.

Parameters
bmainAlmost certainly global main.
libIf not NULL, only make local data-blocks from this library.
untagged_onlyIf true, only make local data-blocks not tagged with LIB_TAG_PRE_EXISTING.
set_fakeIf true, set fake user on all localized data-blocks (except group and objects ones).

Referenced by make_local_exec().

◆ 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,
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 ( struct 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_fake_user_clear()

void id_fake_user_clear ( struct ID id)

◆ id_fake_user_set()

void id_fake_user_set ( struct ID id)

◆ id_lib_extern()

void id_lib_extern ( struct ID id)

◆ id_lib_indirect_weak_link()

void id_lib_indirect_weak_link ( struct ID id)

◆ 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_us_clear_real()

void id_us_clear_real ( struct ID id)

◆ id_us_ensure_real()

void id_us_ensure_real ( struct ID id)

◆ id_us_min()

void id_us_min ( struct 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 ( struct 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)