Blender V4.3
BKE_main_namemap.hh File Reference

Go to the source code of this file.

Functions

UniqueName_MapBKE_main_namemap_create () ATTR_WARN_UNUSED_RESULT
 
void BKE_main_namemap_destroy (UniqueName_Map **r_name_map) ATTR_NONNULL()
 
void BKE_main_namemap_clear (Main *bmain) ATTR_NONNULL()
 
bool BKE_main_namemap_get_name (Main *bmain, ID *id, char *name, const bool do_unique_in_bmain) ATTR_NONNULL()
 
void BKE_main_namemap_remove_name (Main *bmain, ID *id, const char *name) ATTR_NONNULL()
 
bool BKE_main_namemap_validate (Main *bmain) ATTR_NONNULL()
 
bool BKE_main_namemap_validate_and_fix (Main *bmain) ATTR_NONNULL()
 

Detailed Description

API to ensure name uniqueness.

Main database contains the UniqueName_Map which is a cache that tracks names, base names and their suffixes currently in use. So that whenever a new name has to be assigned or validated, it can quickly ensure uniqueness and adjust the name in case of collisions.

Names

  • BKE_main_namemap_ Should be used for functions in this file.

Definition in file BKE_main_namemap.hh.

Function Documentation

◆ BKE_main_namemap_clear()

void BKE_main_namemap_clear ( Main * bmain)

Destroy all name_maps in given bmain:

  • In bmain itself for local IDs.
  • In the split bmains in the list is any (for linked IDs in some cases, e.g. if called during readfile code).
  • In all of the libraries IDs (for linked IDs).

Definition at line 201 of file main_namemap.cc.

References BKE_main_namemap_destroy(), and Main::next.

Referenced by BKE_blendfile_override(), BKE_main_merge(), blo_join_main(), blo_split_main(), main_namemap_validate_and_fix(), and swap_old_bmain_data_for_blendfile().

◆ BKE_main_namemap_create()

UniqueName_Map * BKE_main_namemap_create ( )

Definition at line 179 of file main_namemap.cc.

Referenced by get_namemap_for().

◆ BKE_main_namemap_destroy()

◆ BKE_main_namemap_get_name()

◆ BKE_main_namemap_remove_name()

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

◆ BKE_main_namemap_validate()

◆ BKE_main_namemap_validate_and_fix()

bool BKE_main_namemap_validate_and_fix ( Main * bmain)

Same as BKE_main_namemap_validate, but also fixes any issue by re-generating all name maps, and ensuring again all ID names are unique.

This is typically only used in do_versions code to fix broken files.

Definition at line 611 of file main_namemap.cc.

References BLI_assert, is_valid, and main_namemap_validate_and_fix().

Referenced by after_liblink_merged_bmain_process(), blo_do_versions_300(), do_versions_after_setup(), and write_file_main_validate_pre().