Blender  V2.93
Typedefs | Enumerations | Functions
BKE_lib_remap.h File Reference
#include "BLI_compiler_attrs.h"

Go to the source code of this file.

Typedefs

typedef void(* BKE_library_free_notifier_reference_cb) (const void *)
 
typedef void(* BKE_library_remap_editor_id_reference_cb) (struct ID *, struct ID *)
 

Enumerations

enum  {
  ID_REMAP_SKIP_INDIRECT_USAGE = 1 << 0 , ID_REMAP_SKIP_NEVER_NULL_USAGE = 1 << 1 , ID_REMAP_FLAG_NEVER_NULL_USAGE = 1 << 2 , ID_REMAP_FORCE_NEVER_NULL_USAGE = 1 << 3 ,
  ID_REMAP_NO_INDIRECT_PROXY_DATA_USAGE = 1 << 4 , ID_REMAP_SKIP_OVERRIDE_LIBRARY = 1 << 5 , ID_REMAP_SKIP_USER_CLEAR = 1 << 6 , ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS = 1 << 7
}
 

Functions

void BKE_libblock_remap_locked (struct Main *bmain, void *old_idv, void *new_idv, const short remap_flags) ATTR_NONNULL(1
 
void void BKE_libblock_remap (struct Main *bmain, void *old_idv, void *new_idv, const short remap_flags) ATTR_NONNULL(1
 
void void void BKE_libblock_unlink (struct Main *bmain, void *idv, const bool do_flag_never_null, const bool do_skip_indirect) ATTR_NONNULL()
 
void BKE_libblock_relink_ex (struct Main *bmain, void *idv, void *old_idv, void *new_idv, const short remap_flags) ATTR_NONNULL(1
 
void void BKE_libblock_relink_to_newid (struct ID *id) ATTR_NONNULL()
 
void BKE_library_callback_free_notifier_reference_set (BKE_library_free_notifier_reference_cb func)
 
void BKE_library_callback_remap_editor_id_reference_set (BKE_library_remap_editor_id_reference_cb func)
 

Detailed Description

API to perform remapping from one data-block pointer to another.

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).

Definition in file BKE_lib_remap.h.

Typedef Documentation

◆ BKE_library_free_notifier_reference_cb

typedef void(* BKE_library_free_notifier_reference_cb) (const void *)

Definition at line 112 of file BKE_lib_remap.h.

◆ BKE_library_remap_editor_id_reference_cb

typedef void(* BKE_library_remap_editor_id_reference_cb) (struct ID *, struct ID *)

Definition at line 113 of file BKE_lib_remap.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ID_REMAP_SKIP_INDIRECT_USAGE 

Do not remap indirect usages of IDs (that is, when user is some linked data).

ID_REMAP_SKIP_NEVER_NULL_USAGE 

This flag should always be set, except for 'unlink' scenarios (only relevant when new_id == NULL). Basically, when unset, NEVER_NULL ID usages will keep pointing to old_id, but (if needed) old_id user count will still be decremented. This is mandatory for 'delete ID' case, but in all other situation this would lead to invalid user counts!

ID_REMAP_FLAG_NEVER_NULL_USAGE 

This tells the callback func to flag with #LIB_DOIT all IDs using target one with a 'never NULL' pointer (like e.g. Object.data).

ID_REMAP_FORCE_NEVER_NULL_USAGE 

This tells the callback func to force setting IDs using target one with a 'never NULL' pointer to NULL.

Warning
Use with extreme care, this will leave database in broken state and can cause crashes very easily!
ID_REMAP_NO_INDIRECT_PROXY_DATA_USAGE 

Do not consider proxy/_group pointers of local objects as indirect usages... Our oh-so-beloved proxies again... Do not consider data used by local proxy object as indirect usage. This is needed e.g. in reload scenario, since we have to ensure remapping of Armature data of local proxy is also performed. Usual nightmare...

ID_REMAP_SKIP_OVERRIDE_LIBRARY 

Do not remap library override pointers.

ID_REMAP_SKIP_USER_CLEAR 

Don't touch the user count (use for low level actions such as swapping pointers).

ID_REMAP_FORCE_INTERNAL_RUNTIME_POINTERS 

Force internal ID runtime pointers (like ID.newid, ID.orig_id etc.) to also be processed. This should only be needed in some very specific cases, typically only BKE ID management code should need it (e.g. required from id_delete to ensure no runtime pointer remains using freed ones).

Definition at line 44 of file BKE_lib_remap.h.

Function Documentation

◆ BKE_libblock_relink_ex()

void BKE_libblock_relink_ex ( struct Main bmain,
void *  idv,
void *  old_idv,
void *  new_idv,
const short  remap_flags 
)

◆ BKE_libblock_relink_to_newid()

void void BKE_libblock_relink_to_newid ( ID id)

Similar to #libblock_relink_ex, but is remapping IDs to their newid value if non-NULL, in given id.

Very specific usage, not sure we'll keep it on the long run, currently only used in Object/Collection duplication code...

Definition at line 702 of file lib_remap.c.

References BKE_library_foreach_ID_link(), ID_IS_LINKED, id_relink_to_newid_looper(), and NULL.

Referenced by BKE_collection_duplicate(), BKE_object_duplicate(), BKE_scene_duplicate(), copy_object_set_idnew(), ED_object_add_duplicate(), id_relink_to_newid_looper(), libblock_relink_collection(), make_object_duplilist_real(), and single_object_users().

◆ BKE_libblock_remap()

void void BKE_libblock_remap ( struct Main bmain,
void *  old_idv,
void *  new_idv,
const short  remap_flags 
)

◆ BKE_libblock_remap_locked()

void BKE_libblock_remap_locked ( struct Main bmain,
void *  old_idv,
void *  new_idv,
const short  remap_flags 
)

Referenced by id_delete(), and lib_relocate_do_remap().

◆ BKE_libblock_unlink()

void void void BKE_libblock_unlink ( Main bmain,
void *  idv,
const bool  do_flag_never_null,
const bool  do_skip_indirect 
)

Unlink given id from given bmain (does not touch to indirect, i.e. library, usages of the ID).

Parameters
do_flag_never_nullIf true, all IDs using idv in a 'non-NULL' way are flagged by LIB_TAG_DOIT flag (quite obviously, 'non-NULL' usages can never be unlinked by this function).

Definition at line 573 of file lib_remap.c.

References BKE_libblock_remap_locked(), BKE_main_lock(), BKE_main_unlock(), ID_REMAP_FLAG_NEVER_NULL_USAGE, ID_REMAP_SKIP_INDIRECT_USAGE, and NULL.

Referenced by BKE_id_free_us().

◆ BKE_library_callback_free_notifier_reference_set()

void BKE_library_callback_free_notifier_reference_set ( BKE_library_free_notifier_reference_cb  func)

Definition at line 54 of file lib_remap.c.

References free_notifier_reference_cb.

Referenced by WM_init().

◆ BKE_library_callback_remap_editor_id_reference_set()

void BKE_library_callback_remap_editor_id_reference_set ( BKE_library_remap_editor_id_reference_cb  func)

Definition at line 61 of file lib_remap.c.

References remap_editor_id_reference_cb.

Referenced by WM_init().