Core: rename Session UUID to Session UID

`UUID` generally stands for "universally unique identifier". The session identifier that
we use is neither universally unique, nor does it follow the standard. Therefor, the term
"session uuid" is confusing and should be replaced.

In #116888 we briefly talked about a better name and ended up with "session uid".
The reason for "uid" instead of "id" is that the latter is a very overloaded term in Blender
already.

This patch changes all uses of "uuid" to "uid" where it's used in the context of a
"session uid". It's not always trivial to see whether a specific mention of "uuid" refers
to an actual uuid or something else. Therefore, I might have missed some renames.
I can't think of an automated way to differentiate the case.

BMesh also uses the term "uuid" sometimes in a the wrong context (e.g. `UUIDFaceStepItem`)
but there it also does not mean "session uid", so it's *not* changed by this patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/117350
This commit is contained in:
Jacques Lucke 2024-01-22 13:47:13 +01:00
parent a7354fb2af
commit 311ca3e6af
84 changed files with 546 additions and 549 deletions

View File

@ -69,7 +69,7 @@ set(SRC_DNA_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_screen_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sdna_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sequence_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_session_uuid_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_session_uid_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_shader_fx_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_sound_types.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_space_types.h

View File

@ -29,7 +29,7 @@ class AssetStorage {
StorageT external_assets_;
/* Store local ID assets separately for efficient lookups.
* TODO(Julian): A [ID *, asset] or even [ID.session_uuid, asset] map would be preferable for
* TODO(Julian): A [ID *, asset] or even [ID.session_uid, asset] map would be preferable for
* faster lookups. Not possible until each asset is only represented once in the storage. */
StorageT local_id_assets_;

View File

@ -260,7 +260,7 @@ void BKE_pose_copy_data(struct bPose **dst, const struct bPose *src, bool copy_c
* \note use when copying bones in edit-mode (on returned value from #BKE_pose_channel_ensure)
*/
void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from);
void BKE_pose_channel_session_uuid_generate(struct bPoseChannel *pchan);
void BKE_pose_channel_session_uid_generate(struct bPoseChannel *pchan);
/**
* Return a pointer to the pose channel of the given name
* from this pose.
@ -316,7 +316,7 @@ struct bPoseChannel *BKE_pose_channel_ensure(struct bPose *pose, const char *nam
struct bPoseChannel *BKE_pose_channel_get_mirrored(const struct bPose *pose,
const char *name) ATTR_WARN_UNUSED_RESULT;
void BKE_pose_check_uuids_unique_and_report(const struct bPose *pose);
void BKE_pose_check_uids_unique_and_report(const struct bPose *pose);
#ifndef NDEBUG
bool BKE_pose_channels_is_valid(const struct bPose *pose) ATTR_WARN_UNUSED_RESULT;

View File

@ -22,7 +22,7 @@ class ModifierComputeContext : public ComputeContext {
static constexpr const char *s_static_type = "MODIFIER";
/**
* Use modifier name instead of something like `session_uuid` for now because:
* Use modifier name instead of something like `session_uid` for now because:
* - It's more obvious that the name matches between the original and evaluated object.
* - We might want that the context hash is consistent between sessions in the future.
*/

View File

@ -208,10 +208,10 @@ enum {
G_DEBUG_DEPSGRAPH_TIME = (1 << 11), /* depsgraph timing statistics and messages */
G_DEBUG_DEPSGRAPH_NO_THREADS = (1 << 12), /* single threaded depsgraph */
G_DEBUG_DEPSGRAPH_PRETTY = (1 << 13), /* use pretty colors in depsgraph messages */
G_DEBUG_DEPSGRAPH_UUID = (1 << 14), /* Verify validness of session-wide identifiers
G_DEBUG_DEPSGRAPH_UID = (1 << 14), /* Verify validness of session-wide identifiers
* assigned to ID datablocks */
G_DEBUG_DEPSGRAPH = (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_EVAL | G_DEBUG_DEPSGRAPH_TAG |
G_DEBUG_DEPSGRAPH_TIME | G_DEBUG_DEPSGRAPH_UUID),
G_DEBUG_DEPSGRAPH_TIME | G_DEBUG_DEPSGRAPH_UID),
G_DEBUG_SIMDATA = (1 << 15), /* sim debug data display */
G_DEBUG_GPU = (1 << 16), /* gpu debug */
G_DEBUG_IO = (1 << 17), /* IO Debugging (for Collada, ...). */

View File

@ -48,8 +48,8 @@ enum {
};
struct IDCacheKey {
/* The session UUID of the ID owning the cached data. */
unsigned int id_session_uuid;
/* The session UID of the ID owning the cached data. */
unsigned int id_session_uid;
/* Value uniquely identifying the cache within its ID.
* Typically the offset of its member in the data-block struct, but can be anything. */
size_t identifier;

View File

@ -73,29 +73,29 @@ void BKE_libblock_init_empty(ID *id) ATTR_NONNULL(1);
*/
void BKE_libblock_runtime_reset_remapping_status(ID *id) ATTR_NONNULL(1);
/* *** ID's session_uuid management. *** */
/* *** ID's session_uid management. *** */
/**
* When an ID's UUID is of that value, it is unset/invalid (e.g. for runtime IDs, etc.).
* When an ID's UID is of that value, it is unset/invalid (e.g. for runtime IDs, etc.).
*/
#define MAIN_ID_SESSION_UUID_UNSET 0
#define MAIN_ID_SESSION_UID_UNSET 0
/**
* Generate a session-wise UUID for the given \a id.
* Generate a session-wise UID for the given \a 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.
* loaded or created, undo history is cleared/reset, and so is the UID counter.
*/
void BKE_lib_libblock_session_uuid_ensure(ID *id);
void BKE_lib_libblock_session_uid_ensure(ID *id);
/**
* Re-generate a new session-wise UUID for the given \a id.
* Re-generate a new session-wise UID for the given \a 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.
*/
void BKE_lib_libblock_session_uuid_renew(ID *id);
void BKE_lib_libblock_session_uid_renew(ID *id);
/**
* Generic helper to create a new empty data-block of given type in given \a bmain database.
@ -203,7 +203,7 @@ void BKE_libblock_ensure_unique_name(Main *bmain, ID *id) ATTR_NONNULL();
ID *BKE_libblock_find_name(Main *bmain, short type, const char *name) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL();
ID *BKE_libblock_find_session_uuid(Main *bmain, short type, uint32_t session_uuid);
ID *BKE_libblock_find_session_uid(Main *bmain, short type, uint32_t session_uid);
/**
* Duplicate (a.k.a. deep copy) common processing options.
* See also eDupli_ID_Flags for options controlling what kind of IDs to duplicate.

View File

@ -55,8 +55,8 @@ struct MainIDRelationsEntryItem {
/* For `to_ids` list, an ID used by the hashed ID. */
struct ID **to;
} id_pointer;
/* Session uuid of the `id_pointer`. */
uint session_uuid;
/* Session uid of the `id_pointer`. */
uint session_uid;
int usage_flag; /* Using IDWALK_ enums, defined in BKE_lib_query.hh */
};
@ -67,8 +67,8 @@ struct MainIDRelationsEntry {
/* Linked list of IDs used by that ID. */
struct MainIDRelationsEntryItem *to_ids;
/* Session uuid of the ID matching that entry. */
uint session_uuid;
/* Session uid of the ID matching that entry. */
uint session_uid;
/* Runtime tags, users should ensure those are reset after usage. */
uint tags;
@ -105,7 +105,7 @@ struct MainIDRelations {
/* Mapping from an ID pointer to all of its parents (IDs using it) and children (IDs it uses).
* Values are `MainIDRelationsEntry` pointers. */
struct GHash *relations_from_pointers;
/* NOTE: we could add more mappings when needed (e.g. from session uuid?). */
/* NOTE: we could add more mappings when needed (e.g. from session uid?). */
short flag;

View File

@ -25,7 +25,7 @@ struct Main;
enum {
MAIN_IDMAP_TYPE_NAME = 1 << 0,
MAIN_IDMAP_TYPE_UUID = 1 << 1,
MAIN_IDMAP_TYPE_UID = 1 << 1,
};
/**
@ -57,5 +57,5 @@ ID *BKE_main_idmap_lookup_name(IDNameLib_Map *id_map,
ID *BKE_main_idmap_lookup_id(IDNameLib_Map *id_map, const ID *id) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1, 2);
ID *BKE_main_idmap_lookup_uuid(IDNameLib_Map *id_map, uint session_uuid) ATTR_WARN_UNUSED_RESULT
ID *BKE_main_idmap_lookup_uid(IDNameLib_Map *id_map, uint session_uid) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1);

View File

@ -421,8 +421,8 @@ void BKE_modifier_free(ModifierData *md);
*/
void BKE_modifier_remove_from_list(Object *ob, ModifierData *md);
/* Generate new UUID for the given modifier. */
void BKE_modifier_session_uuid_generate(ModifierData *md);
/* Generate new UID for the given modifier. */
void BKE_modifier_session_uid_generate(ModifierData *md);
void BKE_modifier_unique_name(ListBase *modifiers, ModifierData *md);
@ -472,7 +472,7 @@ void BKE_modifiers_foreach_tex_link(Object *ob, TexWalkFunc walk, void *user_dat
ModifierData *BKE_modifiers_findby_type(const Object *ob, ModifierType type);
ModifierData *BKE_modifiers_findby_name(const Object *ob, const char *name);
ModifierData *BKE_modifiers_findby_session_uuid(const Object *ob, const SessionUUID *session_uuid);
ModifierData *BKE_modifiers_findby_session_uid(const Object *ob, const SessionUID *session_uid);
void BKE_modifiers_clear_errors(Object *ob);
/**
* used for buttons, to find out if the 'draw deformed in edit-mode option is there.
@ -584,7 +584,7 @@ void BKE_modifier_deform_vertsEM(ModifierData *md,
*/
Mesh *BKE_modifier_get_evaluated_mesh_from_evaluated_object(Object *ob_eval);
void BKE_modifier_check_uuids_unique_and_report(const Object *object);
void BKE_modifier_check_uids_unique_and_report(const Object *object);
void BKE_modifier_blend_write(BlendWriter *writer, const ID *id_owner, ListBase *modbase);
void BKE_modifier_blend_read_data(BlendDataReader *reader, ListBase *lb, Object *ob);

View File

@ -685,7 +685,7 @@ Curve *BKE_object_to_curve(Object *object, Depsgraph *depsgraph, bool apply_modi
void BKE_object_to_curve_clear(Object *object);
void BKE_object_check_uuids_unique_and_report(const Object *object);
void BKE_object_check_uids_unique_and_report(const Object *object);
/**
* Return the last subsurf modifier of an object, this does not check whether modifiers on top of

View File

@ -28,7 +28,7 @@
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_session_uuid.h"
#include "BLI_session_uid.h"
#include "BLI_string_utils.hh"
#include "BLI_utildefines.h"
@ -593,9 +593,9 @@ void action_groups_clear_tempflags(bAction *act)
/* *************** Pose channels *************** */
void BKE_pose_channel_session_uuid_generate(bPoseChannel *pchan)
void BKE_pose_channel_session_uid_generate(bPoseChannel *pchan)
{
pchan->runtime.session_uuid = BLI_session_uuid_generate();
pchan->runtime.session_uid = BLI_session_uid_generate();
}
bPoseChannel *BKE_pose_channel_find_name(const bPose *pose, const char *name)
@ -629,7 +629,7 @@ bPoseChannel *BKE_pose_channel_ensure(bPose *pose, const char *name)
/* If not, create it and add it */
chan = static_cast<bPoseChannel *>(MEM_callocN(sizeof(bPoseChannel), "verifyPoseChannel"));
BKE_pose_channel_session_uuid_generate(chan);
BKE_pose_channel_session_uid_generate(chan);
STRNCPY(chan->name, name);
@ -793,7 +793,7 @@ void BKE_pose_copy_data_ex(bPose **dst,
}
if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) {
BKE_pose_channel_session_uuid_generate(pchan);
BKE_pose_channel_session_uid_generate(pchan);
}
/* warning, O(n2) here, if done without the hash, but these are rarely used features. */
@ -1033,9 +1033,9 @@ void BKE_pose_channel_runtime_reset(bPoseChannel_Runtime *runtime)
void BKE_pose_channel_runtime_reset_on_copy(bPoseChannel_Runtime *runtime)
{
const SessionUUID uuid = runtime->session_uuid;
const SessionUID uid = runtime->session_uid;
memset(runtime, 0, sizeof(*runtime));
runtime->session_uuid = uuid;
runtime->session_uid = uid;
}
void BKE_pose_channel_runtime_free(bPoseChannel_Runtime *runtime)
@ -1778,31 +1778,31 @@ void what_does_obaction(Object *ob,
}
}
void BKE_pose_check_uuids_unique_and_report(const bPose *pose)
void BKE_pose_check_uids_unique_and_report(const bPose *pose)
{
if (pose == nullptr) {
return;
}
GSet *used_uuids = BLI_gset_new(
BLI_session_uuid_ghash_hash, BLI_session_uuid_ghash_compare, "sequencer used uuids");
GSet *used_uids = BLI_gset_new(
BLI_session_uid_ghash_hash, BLI_session_uid_ghash_compare, "sequencer used uids");
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
const SessionUUID *session_uuid = &pchan->runtime.session_uuid;
if (!BLI_session_uuid_is_generated(session_uuid)) {
printf("Pose channel %s does not have UUID generated.\n", pchan->name);
const SessionUID *session_uid = &pchan->runtime.session_uid;
if (!BLI_session_uid_is_generated(session_uid)) {
printf("Pose channel %s does not have UID generated.\n", pchan->name);
continue;
}
if (BLI_gset_lookup(used_uuids, session_uuid) != nullptr) {
printf("Pose channel %s has duplicate UUID generated.\n", pchan->name);
if (BLI_gset_lookup(used_uids, session_uid) != nullptr) {
printf("Pose channel %s has duplicate UID generated.\n", pchan->name);
continue;
}
BLI_gset_insert(used_uuids, (void *)session_uuid);
BLI_gset_insert(used_uids, (void *)session_uid);
}
BLI_gset_free(used_uuids, nullptr);
BLI_gset_free(used_uids, nullptr);
}
void BKE_pose_blend_write(BlendWriter *writer, bPose *pose, bArmature *arm)
@ -1868,7 +1868,7 @@ void BKE_pose_blend_read_data(BlendDataReader *reader, ID *id_owner, bPose *pose
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
BKE_pose_channel_runtime_reset(&pchan->runtime);
BKE_pose_channel_session_uuid_generate(pchan);
BKE_pose_channel_session_uid_generate(pchan);
pchan->bone = nullptr;
BLO_read_data_address(reader, &pchan->parent);

View File

@ -373,8 +373,8 @@ static void swap_old_bmain_data_for_blendfile(ReuseOldBMainData *reuse_data, con
}
FOREACH_MAIN_LISTBASE_ID_BEGIN (new_lb, reused_id_iter) {
/* Necessary as all `session_uuid` are renewed on blendfile loading. */
BKE_lib_libblock_session_uuid_renew(reused_id_iter);
/* Necessary as all `session_uid` are renewed on blendfile loading. */
BKE_lib_libblock_session_uid_renew(reused_id_iter);
/* Ensure that the reused ID is remapped to itself, since it is known to be in the `new_bmain`.
*/

View File

@ -32,7 +32,7 @@
uint BKE_idtype_cache_key_hash(const void *key_v)
{
const IDCacheKey *key = static_cast<const IDCacheKey *>(key_v);
size_t hash = BLI_ghashutil_uinthash(key->id_session_uuid);
size_t hash = BLI_ghashutil_uinthash(key->id_session_uid);
hash = BLI_ghashutil_combine_hash(hash, BLI_ghashutil_uinthash(uint(key->identifier)));
return uint(hash);
}
@ -41,7 +41,7 @@ bool BKE_idtype_cache_key_cmp(const void *key_a_v, const void *key_b_v)
{
const IDCacheKey *key_a = static_cast<const IDCacheKey *>(key_a_v);
const IDCacheKey *key_b = static_cast<const IDCacheKey *>(key_b_v);
return (key_a->id_session_uuid != key_b->id_session_uuid) ||
return (key_a->id_session_uid != key_b->id_session_uid) ||
(key_a->identifier != key_b->identifier);
}

View File

@ -235,7 +235,7 @@ static void image_foreach_cache(ID *id,
{
Image *image = (Image *)id;
IDCacheKey key;
key.id_session_uuid = id->session_uuid;
key.id_session_uid = id->session_uid;
key.identifier = offsetof(Image, cache);
function_callback(id, &key, (void **)&image->cache, 0, user_data);

View File

@ -206,9 +206,9 @@ void BKE_lib_id_clear_library_data(Main *bmain, ID *id, const int flags)
}
/* Conceptually, an ID made local is not the same as the linked one anymore. Reflect that by
* regenerating its session UUID. */
* regenerating its session UID. */
if ((id->tag & LIB_TAG_TEMP_MAIN) == 0) {
BKE_lib_libblock_session_uuid_renew(id);
BKE_lib_libblock_session_uid_renew(id);
}
if (ID_IS_ASSET(id)) {
@ -1021,7 +1021,7 @@ void BKE_libblock_management_main_add(Main *bmain, void *idv)
bmain->is_memfile_undo_written = false;
BKE_main_unlock(bmain);
BKE_lib_libblock_session_uuid_ensure(id);
BKE_lib_libblock_session_uid_ensure(id);
}
void BKE_libblock_management_main_remove(Main *bmain, void *idv)
@ -1268,11 +1268,11 @@ void *BKE_libblock_alloc(Main *bmain, short type, const char *name, const int fl
BLI_strncpy(id->name + 2, name, sizeof(id->name) - 2);
}
/* We also need to ensure a valid `session_uuid` for some non-main data (like embedded IDs).
/* We also need to ensure a valid `session_uid` for some non-main data (like embedded IDs).
* IDs not allocated however should not need those (this would e.g. avoid generating session
* uuids for depsgraph CoW IDs, if it was using this function). */
* uids for depsgraph CoW IDs, if it was using this function). */
if ((flag & LIB_ID_CREATE_NO_ALLOCATE) == 0) {
BKE_lib_libblock_session_uuid_ensure(id);
BKE_lib_libblock_session_uid_ensure(id);
}
}
@ -1301,26 +1301,26 @@ void BKE_libblock_runtime_reset_remapping_status(ID *id)
id->runtime.remap.skipped_indirect = 0;
}
/* ********** ID session-wise UUID management. ********** */
static uint global_session_uuid = 0;
/* ********** ID session-wise UID management. ********** */
static uint global_session_uid = 0;
void BKE_lib_libblock_session_uuid_ensure(ID *id)
void BKE_lib_libblock_session_uid_ensure(ID *id)
{
if (id->session_uuid == MAIN_ID_SESSION_UUID_UNSET) {
if (id->session_uid == MAIN_ID_SESSION_UID_UNSET) {
BLI_assert((id->tag & LIB_TAG_TEMP_MAIN) == 0); /* Caller must ensure this. */
id->session_uuid = atomic_add_and_fetch_uint32(&global_session_uuid, 1);
id->session_uid = atomic_add_and_fetch_uint32(&global_session_uid, 1);
/* In case overflow happens, still assign a valid ID. This way opening files many times works
* correctly. */
if (UNLIKELY(id->session_uuid == MAIN_ID_SESSION_UUID_UNSET)) {
id->session_uuid = atomic_add_and_fetch_uint32(&global_session_uuid, 1);
if (UNLIKELY(id->session_uid == MAIN_ID_SESSION_UID_UNSET)) {
id->session_uid = atomic_add_and_fetch_uint32(&global_session_uid, 1);
}
}
}
void BKE_lib_libblock_session_uuid_renew(ID *id)
void BKE_lib_libblock_session_uid_renew(ID *id)
{
id->session_uuid = MAIN_ID_SESSION_UUID_UNSET;
BKE_lib_libblock_session_uuid_ensure(id);
id->session_uid = MAIN_ID_SESSION_UID_UNSET;
BKE_lib_libblock_session_uid_ensure(id);
}
void *BKE_id_new(Main *bmain, const short type, const char *name)
@ -1477,12 +1477,12 @@ ID *BKE_libblock_find_name(Main *bmain, const short type, const char *name)
return static_cast<ID *>(BLI_findstring(lb, name, offsetof(ID, name) + 2));
}
ID *BKE_libblock_find_session_uuid(Main *bmain, const short type, const uint32_t session_uuid)
ID *BKE_libblock_find_session_uid(Main *bmain, const short type, const uint32_t session_uid)
{
ListBase *lb = which_libbase(bmain, type);
BLI_assert(lb != nullptr);
LISTBASE_FOREACH (ID *, id, lb) {
if (id->session_uuid == session_uuid) {
if (id->session_uid == session_uid) {
return id;
}
}

View File

@ -470,17 +470,17 @@ static int main_relations_create_idlink_cb(LibraryIDLinkCallbackData *cb_data)
bmain_relations->relations_from_pointers, self_id, (void ***)&entry_p))
{
*entry_p = static_cast<MainIDRelationsEntry *>(MEM_callocN(sizeof(**entry_p), __func__));
(*entry_p)->session_uuid = self_id->session_uuid;
(*entry_p)->session_uid = self_id->session_uid;
}
else {
BLI_assert((*entry_p)->session_uuid == self_id->session_uuid);
BLI_assert((*entry_p)->session_uid == self_id->session_uid);
}
MainIDRelationsEntryItem *to_id_entry = static_cast<MainIDRelationsEntryItem *>(
BLI_mempool_alloc(bmain_relations->entry_items_pool));
to_id_entry->next = (*entry_p)->to_ids;
to_id_entry->id_pointer.to = id_pointer;
to_id_entry->session_uuid = (*id_pointer != nullptr) ? (*id_pointer)->session_uuid :
MAIN_ID_SESSION_UUID_UNSET;
to_id_entry->session_uid = (*id_pointer != nullptr) ? (*id_pointer)->session_uid :
MAIN_ID_SESSION_UID_UNSET;
to_id_entry->usage_flag = cb_flag;
(*entry_p)->to_ids = to_id_entry;
}
@ -491,16 +491,16 @@ static int main_relations_create_idlink_cb(LibraryIDLinkCallbackData *cb_data)
bmain_relations->relations_from_pointers, *id_pointer, (void ***)&entry_p))
{
*entry_p = static_cast<MainIDRelationsEntry *>(MEM_callocN(sizeof(**entry_p), __func__));
(*entry_p)->session_uuid = (*id_pointer)->session_uuid;
(*entry_p)->session_uid = (*id_pointer)->session_uid;
}
else {
BLI_assert((*entry_p)->session_uuid == (*id_pointer)->session_uuid);
BLI_assert((*entry_p)->session_uid == (*id_pointer)->session_uid);
}
MainIDRelationsEntryItem *from_id_entry = static_cast<MainIDRelationsEntryItem *>(
BLI_mempool_alloc(bmain_relations->entry_items_pool));
from_id_entry->next = (*entry_p)->from_ids;
from_id_entry->id_pointer.from = self_id;
from_id_entry->session_uuid = self_id->session_uuid;
from_id_entry->session_uid = self_id->session_uid;
from_id_entry->usage_flag = cb_flag;
(*entry_p)->from_ids = from_id_entry;
}
@ -533,10 +533,10 @@ void BKE_main_relations_create(Main *bmain, const short flag)
MainIDRelationsEntry **entry_p;
if (!BLI_ghash_ensure_p(bmain->relations->relations_from_pointers, id, (void ***)&entry_p)) {
*entry_p = static_cast<MainIDRelationsEntry *>(MEM_callocN(sizeof(**entry_p), __func__));
(*entry_p)->session_uuid = id->session_uuid;
(*entry_p)->session_uid = id->session_uid;
}
else {
BLI_assert((*entry_p)->session_uuid == id->session_uuid);
BLI_assert((*entry_p)->session_uid == id->session_uid);
}
BKE_library_foreach_ID_link(

View File

@ -54,7 +54,7 @@ struct IDNameLib_TypeMap {
*/
struct IDNameLib_Map {
IDNameLib_TypeMap type_maps[INDEX_ID_MAX];
GHash *uuid_map;
GHash *uid_map;
Main *bmain;
GSet *valid_id_pointers;
int idmap_types;
@ -94,14 +94,14 @@ IDNameLib_Map *BKE_main_idmap_create(Main *bmain,
BLI_assert(index == INDEX_ID_MAX);
id_map->type_maps_keys_pool = nullptr;
if (idmap_types & MAIN_IDMAP_TYPE_UUID) {
if (idmap_types & MAIN_IDMAP_TYPE_UID) {
ID *id;
id_map->uuid_map = BLI_ghash_int_new(__func__);
id_map->uid_map = BLI_ghash_int_new(__func__);
FOREACH_MAIN_ID_BEGIN (bmain, id) {
BLI_assert(id->session_uuid != MAIN_ID_SESSION_UUID_UNSET);
BLI_assert(id->session_uid != MAIN_ID_SESSION_UID_UNSET);
void **id_ptr_v;
const bool existing_key = BLI_ghash_ensure_p(
id_map->uuid_map, POINTER_FROM_UINT(id->session_uuid), &id_ptr_v);
id_map->uid_map, POINTER_FROM_UINT(id->session_uid), &id_ptr_v);
BLI_assert(existing_key == false);
UNUSED_VARS_NDEBUG(existing_key);
@ -110,7 +110,7 @@ IDNameLib_Map *BKE_main_idmap_create(Main *bmain,
FOREACH_MAIN_ID_END;
}
else {
id_map->uuid_map = nullptr;
id_map->uid_map = nullptr;
}
if (create_valid_ids_set) {
@ -144,12 +144,12 @@ void BKE_main_idmap_insert_id(IDNameLib_Map *id_map, ID *id)
}
}
if (id_map->idmap_types & MAIN_IDMAP_TYPE_UUID) {
BLI_assert(id_map->uuid_map != nullptr);
BLI_assert(id->session_uuid != MAIN_ID_SESSION_UUID_UNSET);
if (id_map->idmap_types & MAIN_IDMAP_TYPE_UID) {
BLI_assert(id_map->uid_map != nullptr);
BLI_assert(id->session_uid != MAIN_ID_SESSION_UID_UNSET);
void **id_ptr_v;
const bool existing_key = BLI_ghash_ensure_p(
id_map->uuid_map, POINTER_FROM_UINT(id->session_uuid), &id_ptr_v);
id_map->uid_map, POINTER_FROM_UINT(id->session_uid), &id_ptr_v);
BLI_assert(existing_key == false);
UNUSED_VARS_NDEBUG(existing_key);
@ -174,11 +174,11 @@ void BKE_main_idmap_remove_id(IDNameLib_Map *id_map, ID *id)
}
}
if (id_map->idmap_types & MAIN_IDMAP_TYPE_UUID) {
BLI_assert(id_map->uuid_map != nullptr);
BLI_assert(id->session_uuid != MAIN_ID_SESSION_UUID_UNSET);
if (id_map->idmap_types & MAIN_IDMAP_TYPE_UID) {
BLI_assert(id_map->uid_map != nullptr);
BLI_assert(id->session_uid != MAIN_ID_SESSION_UID_UNSET);
BLI_ghash_remove(id_map->uuid_map, POINTER_FROM_UINT(id->session_uuid), nullptr, nullptr);
BLI_ghash_remove(id_map->uid_map, POINTER_FROM_UINT(id->session_uid), nullptr, nullptr);
}
}
@ -251,10 +251,10 @@ ID *BKE_main_idmap_lookup_id(IDNameLib_Map *id_map, const ID *id)
return nullptr;
}
ID *BKE_main_idmap_lookup_uuid(IDNameLib_Map *id_map, const uint session_uuid)
ID *BKE_main_idmap_lookup_uid(IDNameLib_Map *id_map, const uint session_uid)
{
if (id_map->idmap_types & MAIN_IDMAP_TYPE_UUID) {
return static_cast<ID *>(BLI_ghash_lookup(id_map->uuid_map, POINTER_FROM_UINT(session_uuid)));
if (id_map->idmap_types & MAIN_IDMAP_TYPE_UID) {
return static_cast<ID *>(BLI_ghash_lookup(id_map->uid_map, POINTER_FROM_UINT(session_uid)));
}
return nullptr;
}
@ -274,8 +274,8 @@ void BKE_main_idmap_destroy(IDNameLib_Map *id_map)
id_map->type_maps_keys_pool = nullptr;
}
}
if (id_map->idmap_types & MAIN_IDMAP_TYPE_UUID) {
BLI_ghash_free(id_map->uuid_map, nullptr, nullptr);
if (id_map->idmap_types & MAIN_IDMAP_TYPE_UID) {
BLI_ghash_free(id_map->uid_map, nullptr, nullptr);
}
BLI_assert(id_map->type_maps_keys_pool == nullptr);

View File

@ -36,7 +36,7 @@
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_session_uuid.h"
#include "BLI_session_uid.h"
#include "BLI_string.h"
#include "BLI_string_utf8.h"
#include "BLI_string_utils.hh"
@ -162,7 +162,7 @@ ModifierData *BKE_modifier_new(int type)
{
ModifierData *md = modifier_allocate_and_init(ModifierType(type));
BKE_modifier_session_uuid_generate(md);
BKE_modifier_session_uid_generate(md);
return md;
}
@ -220,9 +220,9 @@ void BKE_modifier_remove_from_list(Object *ob, ModifierData *md)
BLI_remlink(&ob->modifiers, md);
}
void BKE_modifier_session_uuid_generate(ModifierData *md)
void BKE_modifier_session_uid_generate(ModifierData *md)
{
md->session_uuid = BLI_session_uuid_generate();
md->session_uid = BLI_session_uid_generate();
}
void BKE_modifier_unique_name(ListBase *modifiers, ModifierData *md)
@ -266,10 +266,10 @@ ModifierData *BKE_modifiers_findby_name(const Object *ob, const char *name)
BLI_findstring(&(ob->modifiers), name, offsetof(ModifierData, name)));
}
ModifierData *BKE_modifiers_findby_session_uuid(const Object *ob, const SessionUUID *session_uuid)
ModifierData *BKE_modifiers_findby_session_uid(const Object *ob, const SessionUID *session_uid)
{
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (BLI_session_uuid_is_equal(&md->session_uuid, session_uuid)) {
if (BLI_session_uid_is_equal(&md->session_uid, session_uid)) {
return md;
}
}
@ -370,14 +370,14 @@ void BKE_modifier_copydata_ex(const ModifierData *md, ModifierData *target, cons
}
if (flag & LIB_ID_CREATE_NO_MAIN) {
/* Make sure UUID is the same between the source and the target.
* This is needed in the cases when UUID is to be preserved and when there is no copy_data
/* Make sure UID is the same between the source and the target.
* This is needed in the cases when UID is to be preserved and when there is no copy_data
* callback, or the copy_data does not do full byte copy of the modifier data. */
target->session_uuid = md->session_uuid;
target->session_uid = md->session_uid;
}
else {
/* In the case copy_data made full byte copy force UUID to be re-generated. */
BKE_modifier_session_uuid_generate(target);
/* In the case copy_data made full byte copy force UID to be re-generated. */
BKE_modifier_session_uid_generate(target);
}
}
@ -985,7 +985,7 @@ Mesh *BKE_modifier_get_evaluated_mesh_from_evaluated_object(Object *ob_eval)
ModifierData *BKE_modifier_get_original(const Object *object, ModifierData *md)
{
const Object *object_orig = DEG_get_original_object((Object *)object);
return BKE_modifiers_findby_session_uuid(object_orig, &md->session_uuid);
return BKE_modifiers_findby_session_uid(object_orig, &md->session_uid);
}
ModifierData *BKE_modifier_get_evaluated(Depsgraph *depsgraph, Object *object, ModifierData *md)
@ -994,30 +994,30 @@ ModifierData *BKE_modifier_get_evaluated(Depsgraph *depsgraph, Object *object, M
if (object_eval == object) {
return md;
}
return BKE_modifiers_findby_session_uuid(object_eval, &md->session_uuid);
return BKE_modifiers_findby_session_uid(object_eval, &md->session_uid);
}
void BKE_modifier_check_uuids_unique_and_report(const Object *object)
void BKE_modifier_check_uids_unique_and_report(const Object *object)
{
GSet *used_uuids = BLI_gset_new(
BLI_session_uuid_ghash_hash, BLI_session_uuid_ghash_compare, "modifier used uuids");
GSet *used_uids = BLI_gset_new(
BLI_session_uid_ghash_hash, BLI_session_uid_ghash_compare, "modifier used uids");
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
const SessionUUID *session_uuid = &md->session_uuid;
if (!BLI_session_uuid_is_generated(session_uuid)) {
printf("Modifier %s -> %s does not have UUID generated.\n", object->id.name + 2, md->name);
const SessionUID *session_uid = &md->session_uid;
if (!BLI_session_uid_is_generated(session_uid)) {
printf("Modifier %s -> %s does not have UID generated.\n", object->id.name + 2, md->name);
continue;
}
if (BLI_gset_lookup(used_uuids, session_uuid) != nullptr) {
printf("Modifier %s -> %s has duplicate UUID generated.\n", object->id.name + 2, md->name);
if (BLI_gset_lookup(used_uids, session_uid) != nullptr) {
printf("Modifier %s -> %s has duplicate UID generated.\n", object->id.name + 2, md->name);
continue;
}
BLI_gset_insert(used_uuids, (void *)session_uuid);
BLI_gset_insert(used_uids, (void *)session_uid);
}
BLI_gset_free(used_uuids, nullptr);
BLI_gset_free(used_uids, nullptr);
}
void BKE_modifier_blend_write(BlendWriter *writer, const ID *id_owner, ListBase *modbase)
@ -1245,7 +1245,7 @@ void BKE_modifier_blend_read_data(BlendDataReader *reader, ListBase *lb, Object
BLO_read_list(reader, lb);
LISTBASE_FOREACH (ModifierData *, md, lb) {
BKE_modifier_session_uuid_generate(md);
BKE_modifier_session_uid_generate(md);
md->error = nullptr;
md->runtime = nullptr;

View File

@ -141,7 +141,7 @@ static void movie_clip_foreach_cache(ID *id,
{
MovieClip *movie_clip = (MovieClip *)id;
IDCacheKey key{};
key.id_session_uuid = id->session_uuid;
key.id_session_uid = id->session_uid;
key.identifier = offsetof(MovieClip, cache);
function_callback(id, &key, (void **)&movie_clip->cache, 0, user_data);

View File

@ -398,7 +398,7 @@ static void node_foreach_cache(ID *id,
{
bNodeTree *nodetree = reinterpret_cast<bNodeTree *>(id);
IDCacheKey key = {0};
key.id_session_uuid = id->session_uuid;
key.id_session_uid = id->session_uid;
key.identifier = offsetof(bNodeTree, previews);
/* TODO: see also `direct_link_nodetree()` in `readfile.cc`. */

View File

@ -5336,10 +5336,10 @@ void BKE_object_to_curve_clear(Object *object)
object->runtime->object_as_temp_curve = nullptr;
}
void BKE_object_check_uuids_unique_and_report(const Object *object)
void BKE_object_check_uids_unique_and_report(const Object *object)
{
BKE_pose_check_uuids_unique_and_report(object->pose);
BKE_modifier_check_uuids_unique_and_report(object);
BKE_pose_check_uids_unique_and_report(object->pose);
BKE_modifier_check_uids_unique_and_report(object);
}
SubsurfModifierData *BKE_object_get_last_subsurf_modifier(const Object *ob)

View File

@ -417,7 +417,7 @@ static void make_child_duplis(const DupliContext *ctx,
}
else {
/* FIXME: using a mere counter to generate a 'persistent' dupli id is very weak. One possible
* better solution could be to use `session_uuid` of ID's instead? */
* better solution could be to use `session_uid` of ID's instead? */
int persistent_dupli_id = 0;
DEGObjectIterSettings deg_iter_settings{};
deg_iter_settings.depsgraph = ctx->depsgraph;

View File

@ -498,8 +498,8 @@ static void scene_foreach_toolsettings_id_pointer_process(
ID *id_old = *id_old_p;
/* Old data has not been remapped to new values of the pointers, if we want to keep the old
* pointer here we need its new address. */
ID *id_old_new = id_old != nullptr ? BLO_read_get_new_id_address_from_session_uuid(
reader, id_old->session_uuid) :
ID *id_old_new = id_old != nullptr ? BLO_read_get_new_id_address_from_session_uid(
reader, id_old->session_uid) :
nullptr;
/* The new address may be the same as the old one, in which case there is nothing to do. */
if (id_old_new == id_old) {
@ -521,10 +521,10 @@ static void scene_foreach_toolsettings_id_pointer_process(
* There is a nasty twist here though: a previous call to 'undo_preserve' on the Scene ID may
* have modified it, even though the undo step detected it as unmodified. In such case, the
* value of `*id_p` may end up also pointing to an invalid (no more in newly read Main) ID,
* so it also needs to be checked from its `session_uuid`. */
* so it also needs to be checked from its `session_uid`. */
ID *id = *id_p;
ID *id_new = id != nullptr ?
BLO_read_get_new_id_address_from_session_uuid(reader, id->session_uuid) :
BLO_read_get_new_id_address_from_session_uid(reader, id->session_uid) :
nullptr;
if (id_new != id) {
*id_p = id_new;
@ -964,7 +964,7 @@ static void scene_foreach_cache(ID *id,
{
Scene *scene = (Scene *)id;
IDCacheKey key{};
key.id_session_uuid = id->session_uuid;
key.id_session_uid = id->session_uid;
key.identifier = offsetof(Scene, eevee.light_cache_data);
function_callback(id,

View File

@ -121,7 +121,7 @@ static void sound_foreach_cache(ID *id,
{
bSound *sound = (bSound *)id;
IDCacheKey key{};
key.id_session_uuid = id->session_uuid;
key.id_session_uid = id->session_uid;
key.identifier = offsetof(bSound, waveform);
function_callback(id, &key, &sound->waveform, 0, user_data);

View File

@ -202,7 +202,7 @@ static void volume_foreach_cache(ID *id,
{
Volume *volume = (Volume *)id;
IDCacheKey key = {
/*id_session_uuid*/ id->session_uuid,
/*id_session_uid*/ id->session_uid,
/*identifier*/ 1,
};

View File

@ -0,0 +1,64 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup bli
*
* Functions for generating and handling "Session UIDs".
*
* Note that these are not true universally-unique identifiers, but only unique during the current
* Blender session.
*
* For true UUIDs, see `BLI_uuid.h`.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "DNA_session_uid_types.h"
/** Generate new UID which is unique throughout the Blender session. */
SessionUID BLI_session_uid_generate(void);
/** Check whether the UID is properly generated. */
bool BLI_session_uid_is_generated(const SessionUID *uid);
/** Check whether two UIDs are identical. */
bool BLI_session_uid_is_equal(const SessionUID *lhs, const SessionUID *rhs);
uint64_t BLI_session_uid_hash_uint64(const SessionUID *uid);
/* Utility functions to make it possible to create GHash/GSet with UID as a key. */
uint BLI_session_uid_ghash_hash(const void *uid_v);
bool BLI_session_uid_ghash_compare(const void *lhs_v, const void *rhs_v);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
namespace blender {
inline const bool operator==(const SessionUID &lhs, const SessionUID &rhs)
{
return BLI_session_uid_is_equal(&lhs, &rhs);
}
template<typename T> struct DefaultHash;
template<> struct DefaultHash<SessionUID> {
uint64_t operator()(const SessionUID &value) const
{
return BLI_session_uid_hash_uint64(&value);
}
};
} // namespace blender
#endif

View File

@ -1,64 +0,0 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
/** \file
* \ingroup bli
*
* Functions for generating and handling "Session UUIDs".
*
* Note that these are not true universally-unique identifiers, but only unique during the current
* Blender session.
*
* For true UUIDs, see `BLI_uuid.h`.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "DNA_session_uuid_types.h"
/** Generate new UUID which is unique throughout the Blender session. */
SessionUUID BLI_session_uuid_generate(void);
/** Check whether the UUID is properly generated. */
bool BLI_session_uuid_is_generated(const SessionUUID *uuid);
/** Check whether two UUIDs are identical. */
bool BLI_session_uuid_is_equal(const SessionUUID *lhs, const SessionUUID *rhs);
uint64_t BLI_session_uuid_hash_uint64(const SessionUUID *uuid);
/* Utility functions to make it possible to create GHash/GSet with UUID as a key. */
uint BLI_session_uuid_ghash_hash(const void *uuid_v);
bool BLI_session_uuid_ghash_compare(const void *lhs_v, const void *rhs_v);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
namespace blender {
inline const bool operator==(const SessionUUID &lhs, const SessionUUID &rhs)
{
return BLI_session_uuid_is_equal(&lhs, &rhs);
}
template<typename T> struct DefaultHash;
template<> struct DefaultHash<SessionUUID> {
uint64_t operator()(const SessionUUID &value) const
{
return BLI_session_uuid_hash_uint64(&value);
}
};
} // namespace blender
#endif

View File

@ -10,7 +10,7 @@
* Functions for generating and handling UUID structs according to RFC4122.
*
* Note that these are true UUIDs, not to be confused with the "session uuid" defined in
* `BLI_session_uuid.h`.
* `BLI_session_uid.h`.
*/
#include "DNA_uuid_types.h"

View File

@ -132,7 +132,7 @@ set(SRC
intern/scanfill.c
intern/scanfill_utils.c
intern/serialize.cc
intern/session_uuid.c
intern/session_uid.c
intern/smaa_textures.c
intern/sort.c
intern/sort_utils.c
@ -335,7 +335,7 @@ set(SRC
BLI_resource_scope.hh
BLI_scanfill.h
BLI_serialize.hh
BLI_session_uuid.h
BLI_session_uid.h
BLI_set.hh
BLI_set_slots.hh
BLI_shared_cache.hh
@ -544,7 +544,7 @@ if(WITH_GTESTS)
tests/BLI_pool_test.cc
tests/BLI_ressource_strings.h
tests/BLI_serialize_test.cc
tests/BLI_session_uuid_test.cc
tests/BLI_session_uid_test.cc
tests/BLI_set_test.cc
tests/BLI_span_test.cc
tests/BLI_stack_cxx_test.cc

View File

@ -0,0 +1,66 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup bli
*/
#include "BLI_session_uid.h"
#include "BLI_utildefines.h"
#include "atomic_ops.h"
/* Special value which indicates the UID has not been assigned yet. */
#define BLI_session_uid_NONE 0
static const SessionUID global_session_uid_none = {BLI_session_uid_NONE};
/* Denotes last used UID.
* It might eventually overflow, and easiest is to add more bits to it. */
static SessionUID global_session_uid = {BLI_session_uid_NONE};
SessionUID BLI_session_uid_generate(void)
{
SessionUID result;
result.uid_ = atomic_add_and_fetch_uint64(&global_session_uid.uid_, 1);
if (!BLI_session_uid_is_generated(&result)) {
/* Happens when the UID overflows.
*
* Just request the UID once again, hoping that there are not a lot of high-priority threads
* which will overflow the counter once again between the previous call and this one.
*
* NOTE: It is possible to have collisions after such overflow. */
result.uid_ = atomic_add_and_fetch_uint64(&global_session_uid.uid_, 1);
}
return result;
}
bool BLI_session_uid_is_generated(const SessionUID *uid)
{
return !BLI_session_uid_is_equal(uid, &global_session_uid_none);
}
bool BLI_session_uid_is_equal(const SessionUID *lhs, const SessionUID *rhs)
{
return lhs->uid_ == rhs->uid_;
}
uint64_t BLI_session_uid_hash_uint64(const SessionUID *uid)
{
return uid->uid_;
}
uint BLI_session_uid_ghash_hash(const void *uid_v)
{
const SessionUID *uid = (const SessionUID *)uid_v;
return uid->uid_ & 0xffffffff;
}
bool BLI_session_uid_ghash_compare(const void *lhs_v, const void *rhs_v)
{
const SessionUID *lhs = (const SessionUID *)lhs_v;
const SessionUID *rhs = (const SessionUID *)rhs_v;
return !BLI_session_uid_is_equal(lhs, rhs);
}

View File

@ -1,66 +0,0 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup bli
*/
#include "BLI_session_uuid.h"
#include "BLI_utildefines.h"
#include "atomic_ops.h"
/* Special value which indicates the UUID has not been assigned yet. */
#define BLI_SESSION_UUID_NONE 0
static const SessionUUID global_session_uuid_none = {BLI_SESSION_UUID_NONE};
/* Denotes last used UUID.
* It might eventually overflow, and easiest is to add more bits to it. */
static SessionUUID global_session_uuid = {BLI_SESSION_UUID_NONE};
SessionUUID BLI_session_uuid_generate(void)
{
SessionUUID result;
result.uuid_ = atomic_add_and_fetch_uint64(&global_session_uuid.uuid_, 1);
if (!BLI_session_uuid_is_generated(&result)) {
/* Happens when the UUID overflows.
*
* Just request the UUID once again, hoping that there are not a lot of high-priority threads
* which will overflow the counter once again between the previous call and this one.
*
* NOTE: It is possible to have collisions after such overflow. */
result.uuid_ = atomic_add_and_fetch_uint64(&global_session_uuid.uuid_, 1);
}
return result;
}
bool BLI_session_uuid_is_generated(const SessionUUID *uuid)
{
return !BLI_session_uuid_is_equal(uuid, &global_session_uuid_none);
}
bool BLI_session_uuid_is_equal(const SessionUUID *lhs, const SessionUUID *rhs)
{
return lhs->uuid_ == rhs->uuid_;
}
uint64_t BLI_session_uuid_hash_uint64(const SessionUUID *uuid)
{
return uuid->uuid_;
}
uint BLI_session_uuid_ghash_hash(const void *uuid_v)
{
const SessionUUID *uuid = (const SessionUUID *)uuid_v;
return uuid->uuid_ & 0xffffffff;
}
bool BLI_session_uuid_ghash_compare(const void *lhs_v, const void *rhs_v)
{
const SessionUUID *lhs = (const SessionUUID *)lhs_v;
const SessionUUID *rhs = (const SessionUUID *)rhs_v;
return !BLI_session_uuid_is_equal(lhs, rhs);
}

View File

@ -0,0 +1,22 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: Apache-2.0 */
#include "testing/testing.h"
#include "BLI_session_uid.h"
TEST(SessionUID, GenerateBasic)
{
{
const SessionUID uid = BLI_session_uid_generate();
EXPECT_TRUE(BLI_session_uid_is_generated(&uid));
}
{
const SessionUID uid1 = BLI_session_uid_generate();
const SessionUID uid2 = BLI_session_uid_generate();
EXPECT_FALSE(BLI_session_uid_is_equal(&uid1, &uid2));
}
}

View File

@ -1,22 +0,0 @@
/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: Apache-2.0 */
#include "testing/testing.h"
#include "BLI_session_uuid.h"
TEST(SessionUUID, GenerateBasic)
{
{
const SessionUUID uuid = BLI_session_uuid_generate();
EXPECT_TRUE(BLI_session_uuid_is_generated(&uuid));
}
{
const SessionUUID uuid1 = BLI_session_uuid_generate();
const SessionUUID uuid2 = BLI_session_uuid_generate();
EXPECT_FALSE(BLI_session_uuid_is_equal(&uuid1, &uuid2));
}
}

View File

@ -277,9 +277,9 @@ ID *BLO_read_get_new_id_address(BlendLibReader *reader,
ID *id) ATTR_NONNULL(2);
/**
* Search for the new address of the ID for the given `session_uuid`.
* Search for the new address of the ID for the given `session_uid`.
*
* Only IDs existing in the newly read Main will be returned. If no matching `session_uuid` in new
* Only IDs existing in the newly read Main will be returned. If no matching `session_uid` in new
* main can be found, `nullptr` is returned.
*
* This expected to be used during library-linking and/or 'undo_preserve' processes in undo case
@ -287,7 +287,7 @@ ID *BLO_read_get_new_id_address(BlendLibReader *reader,
* coming from the previous, existing Main data, when it is preserved in newly read Main.
* See e.g. the #scene_undo_preserve code-path.
*/
ID *BLO_read_get_new_id_address_from_session_uuid(BlendLibReader *reader, uint session_uuid)
ID *BLO_read_get_new_id_address_from_session_uid(BlendLibReader *reader, uint session_uid)
ATTR_NONNULL(1);
/* Misc. */

View File

@ -27,9 +27,9 @@ struct MemFileChunk {
* detect unchanged IDs).
* Defined when writing the next step (i.e. last undo step has those always false). */
bool is_identical_future;
/** Session UUID of the ID being currently written (MAIN_ID_SESSION_UUID_UNSET when not writing
/** Session UID of the ID being currently written (MAIN_ID_SESSION_UID_UNSET when not writing
* ID-related data). Used to find matching chunks in previous memundo step. */
uint id_session_uuid;
uint id_session_uid;
};
struct MemFile {
@ -41,11 +41,11 @@ struct MemFileWriteData {
MemFile *written_memfile;
MemFile *reference_memfile;
uint current_id_session_uuid;
uint current_id_session_uid;
MemFileChunk *reference_current_chunk;
/** Maps an ID session uuid to its first reference MemFileChunk, if existing. */
blender::Map<uint, MemFileChunk *> id_session_uuid_mapping;
/** Maps an ID session uid to its first reference MemFileChunk, if existing. */
blender::Map<uint, MemFileChunk *> id_session_uid_mapping;
};
struct MemFileUndoData {

View File

@ -1354,11 +1354,11 @@ void blo_filedata_free(FileData *fd)
if (fd->libmap && !(fd->flags & FD_FLAGS_NOT_MY_LIBMAP)) {
oldnewmap_free(fd->libmap);
}
if (fd->old_idmap_uuid != nullptr) {
BKE_main_idmap_destroy(fd->old_idmap_uuid);
if (fd->old_idmap_uid != nullptr) {
BKE_main_idmap_destroy(fd->old_idmap_uid);
}
if (fd->new_idmap_uuid != nullptr) {
BKE_main_idmap_destroy(fd->new_idmap_uuid);
if (fd->new_idmap_uid != nullptr) {
BKE_main_idmap_destroy(fd->new_idmap_uid);
}
blo_cache_storage_end(fd);
if (fd->bheadmap) {
@ -1591,10 +1591,10 @@ void blo_end_packed_pointer_map(FileData *fd, Main *oldmain)
void blo_make_old_idmap_from_main(FileData *fd, Main *bmain)
{
if (fd->old_idmap_uuid != nullptr) {
BKE_main_idmap_destroy(fd->old_idmap_uuid);
if (fd->old_idmap_uid != nullptr) {
BKE_main_idmap_destroy(fd->old_idmap_uid);
}
fd->old_idmap_uuid = BKE_main_idmap_create(bmain, false, nullptr, MAIN_IDMAP_TYPE_UUID);
fd->old_idmap_uid = BKE_main_idmap_create(bmain, false, nullptr, MAIN_IDMAP_TYPE_UID);
}
struct BLOCacheStorage {
@ -1611,7 +1611,7 @@ struct BLOCacheStorageValue {
static void blo_cache_storage_entry_register(
ID *id, const IDCacheKey *key, void **cache_p, uint /*flags*/, void *cache_storage_v)
{
BLI_assert(key->id_session_uuid == id->session_uuid);
BLI_assert(key->id_session_uid == id->session_uid);
UNUSED_VARS_NDEBUG(id);
BLOCacheStorage *cache_storage = static_cast<BLOCacheStorage *>(cache_storage_v);
@ -2069,13 +2069,13 @@ static void direct_link_id_common(
BlendDataReader *reader, Library *current_library, ID *id, ID *id_old, const int id_tag)
{
if (!BLO_read_data_is_undo(reader)) {
/* When actually reading a file, we do want to reset/re-generate session UUIDS.
/* When actually reading a file, we do want to reset/re-generate session UIDS.
* In undo case, we want to re-use existing ones. */
id->session_uuid = MAIN_ID_SESSION_UUID_UNSET;
id->session_uid = MAIN_ID_SESSION_UID_UNSET;
}
if ((id_tag & LIB_TAG_TEMP_MAIN) == 0) {
BKE_lib_libblock_session_uuid_ensure(id);
BKE_lib_libblock_session_uid_ensure(id);
}
id->lib = current_library;
@ -2383,7 +2383,7 @@ static ID *create_placeholder(Main *mainvar,
}
if ((tag & LIB_TAG_TEMP_MAIN) == 0) {
BKE_lib_libblock_session_uuid_ensure(ph_id);
BKE_lib_libblock_session_uid_ensure(ph_id);
}
return ph_id;
@ -2625,7 +2625,7 @@ static void read_undo_reuse_noundo_local_ids(FileData *fd)
/* Update mappings accordingly. */
LISTBASE_FOREACH (ID *, id_iter, new_lb) {
BKE_main_idmap_insert_id(fd->new_idmap_uuid, id_iter);
BKE_main_idmap_insert_id(fd->new_idmap_uid, id_iter);
id_iter->tag |= LIB_TAG_UNDO_OLD_ID_REUSED_NOUNDO;
}
}
@ -2642,14 +2642,14 @@ static void read_undo_move_libmain_data(
BLI_addtail(&new_main->libraries, libmain->curlib);
curlib->id.tag |= LIB_TAG_UNDO_OLD_ID_REUSED_NOUNDO;
BKE_main_idmap_insert_id(fd->new_idmap_uuid, &curlib->id);
BKE_main_idmap_insert_id(fd->new_idmap_uid, &curlib->id);
if (bhead != nullptr) {
oldnewmap_lib_insert(fd, bhead->old, &curlib->id, GS(curlib->id.name));
}
ID *id_iter;
FOREACH_MAIN_ID_BEGIN (libmain, id_iter) {
BKE_main_idmap_insert_id(fd->new_idmap_uuid, id_iter);
BKE_main_idmap_insert_id(fd->new_idmap_uid, id_iter);
}
FOREACH_MAIN_ID_END;
}
@ -2709,7 +2709,7 @@ static bool read_libblock_undo_restore_linked(
CLOG_INFO(&LOG_UNDO, 2, "UNDO: restore linked datablock %s", id->name);
if (*r_id_old == nullptr) {
/* If the linked ID had to be re-read at some point, its session_uuid may not be the same as
/* If the linked ID had to be re-read at some point, its session_uid may not be the same as
* its reference stored in the memfile anymore. Do a search by name then. */
*r_id_old = library_id_is_yet_read(fd, libmain, bhead);
@ -2729,19 +2729,19 @@ static bool read_libblock_undo_restore_linked(
libmain->curlib ? libmain->curlib->filepath : "<nullptr>");
/* The Library ID 'owning' this linked ID should already have been moved to new main by a call
* to #read_libblock_undo_restore_library. */
BLI_assert(*r_id_old == static_cast<ID *>(BKE_main_idmap_lookup_uuid(
fd->new_idmap_uuid, (*r_id_old)->session_uuid)));
BLI_assert(*r_id_old == static_cast<ID *>(BKE_main_idmap_lookup_uid(
fd->new_idmap_uid, (*r_id_old)->session_uid)));
}
else {
CLOG_INFO(&LOG_UNDO,
2,
" from %s (%s): found by session_uuid",
" from %s (%s): found by session_uid",
libmain->curlib ? libmain->curlib->id.name : "<nullptr>",
libmain->curlib ? libmain->curlib->filepath : "<nullptr>");
/* The Library ID 'owning' this linked ID should already have been moved to new main by a call
* to #read_libblock_undo_restore_library. */
BLI_assert(*r_id_old == static_cast<ID *>(
BKE_main_idmap_lookup_uuid(fd->new_idmap_uuid, id->session_uuid)));
BLI_assert(*r_id_old ==
static_cast<ID *>(BKE_main_idmap_lookup_uid(fd->new_idmap_uid, id->session_uid)));
}
oldnewmap_lib_insert(fd, bhead->old, *r_id_old, GS((*r_id_old)->name));
@ -2789,7 +2789,7 @@ static void read_libblock_undo_restore_identical(
* remapped, so no need to store this info here. */
oldnewmap_lib_insert(fd, bhead->old, id_old, bhead->code);
BKE_main_idmap_insert_id(fd->new_idmap_uuid, id_old);
BKE_main_idmap_insert_id(fd->new_idmap_uid, id_old);
if (GS(id_old->name) == ID_OB) {
Object *ob = (Object *)id_old;
@ -2843,7 +2843,7 @@ static void read_libblock_undo_restore_at_old_address(FileData *fd, Main *main,
static bool read_libblock_undo_restore(
FileData *fd, Main *main, BHead *bhead, int id_tag, ID **r_id_old)
{
BLI_assert(fd->old_idmap_uuid != nullptr);
BLI_assert(fd->old_idmap_uid != nullptr);
/* Get pointer to memory of new ID that we will be reading. */
const ID *id = static_cast<const ID *>(peek_struct_undo(fd, bhead));
@ -2859,8 +2859,8 @@ static bool read_libblock_undo_restore(
/* Find the 'current' existing ID we want to reuse instead of the one we
* would read from the undo memfile. */
ID *id_old = (fd->old_idmap_uuid != nullptr) ?
BKE_main_idmap_lookup_uuid(fd->old_idmap_uuid, id->session_uuid) :
ID *id_old = (fd->old_idmap_uid != nullptr) ?
BKE_main_idmap_lookup_uid(fd->old_idmap_uid, id->session_uid) :
nullptr;
if (bhead->code == ID_LI) {
@ -2881,14 +2881,14 @@ static bool read_libblock_undo_restore(
/* If that local noundo ID still exists currently, the call to
* #read_undo_reuse_noundo_local_ids at the beginning of #blo_read_file_internal will already
* have moved it into the new main, and populated accordingly the new_idmap_uuid.
* have moved it into the new main, and populated accordingly the new_idmap_uid.
*
* If this is the case, it can also be remapped for newly read data. Otherwise, this is 'lost'
* data that cannot be restored on undo, so no remapping should exist for it in the ID
* oldnewmap. */
if (id_old) {
BLI_assert(id_old == static_cast<ID *>(
BKE_main_idmap_lookup_uuid(fd->new_idmap_uuid, id->session_uuid)));
BLI_assert(id_old ==
static_cast<ID *>(BKE_main_idmap_lookup_uid(fd->new_idmap_uid, id->session_uid)));
oldnewmap_lib_insert(fd, bhead->old, id_old, bhead->code);
}
return true;
@ -2897,9 +2897,9 @@ static bool read_libblock_undo_restore(
if (!do_partial_undo) {
CLOG_INFO(&LOG_UNDO,
2,
"UNDO: read %s (uuid %u) -> no partial undo, always read at new address",
"UNDO: read %s (uid %u) -> no partial undo, always read at new address",
id->name,
id->session_uuid);
id->session_uid);
return false;
}
@ -2908,9 +2908,9 @@ static bool read_libblock_undo_restore(
/* Local datablock was unchanged, restore from the old main. */
CLOG_INFO(&LOG_UNDO,
2,
"UNDO: read %s (uuid %u) -> keep identical datablock",
"UNDO: read %s (uid %u) -> keep identical datablock",
id->name,
id->session_uuid);
id->session_uid);
read_libblock_undo_restore_identical(fd, main, id, id_old, bhead, id_tag);
@ -2921,16 +2921,16 @@ static bool read_libblock_undo_restore(
/* Local datablock was changed. Restore at the address of the old datablock. */
CLOG_INFO(&LOG_UNDO,
2,
"UNDO: read %s (uuid %u) -> read to old existing address",
"UNDO: read %s (uid %u) -> read to old existing address",
id->name,
id->session_uuid);
id->session_uid);
*r_id_old = id_old;
return false;
}
/* Local datablock does not exist in the undo step, so read from scratch. */
CLOG_INFO(
&LOG_UNDO, 2, "UNDO: read %s (uuid %u) -> read at new address", id->name, id->session_uuid);
&LOG_UNDO, 2, "UNDO: read %s (uid %u) -> read at new address", id->name, id->session_uid);
return false;
}
@ -3051,8 +3051,8 @@ static BHead *read_libblock(FileData *fd,
/* For undo, store contents read into id at id_old. */
read_libblock_undo_restore_at_old_address(fd, main, id, id_old);
}
if (fd->new_idmap_uuid != nullptr) {
BKE_main_idmap_insert_id(fd->new_idmap_uuid, id_target);
if (fd->new_idmap_uid != nullptr) {
BKE_main_idmap_insert_id(fd->new_idmap_uid, id_target);
}
if (main->id_map != nullptr) {
BKE_main_idmap_insert_id(main->id_map, id_target);
@ -3520,10 +3520,10 @@ static int read_undo_remap_noundo_data_cb(LibraryIDLinkCallbackData *cb_data)
return IDWALK_RET_NOP;
}
IDNameLib_Map *new_idmap_uuid = static_cast<IDNameLib_Map *>(cb_data->user_data);
IDNameLib_Map *new_idmap_uid = static_cast<IDNameLib_Map *>(cb_data->user_data);
ID **id_pointer = cb_data->id_pointer;
if (*id_pointer != nullptr) {
*id_pointer = BKE_main_idmap_lookup_uuid(new_idmap_uuid, (*id_pointer)->session_uuid);
*id_pointer = BKE_main_idmap_lookup_uid(new_idmap_uid, (*id_pointer)->session_uid);
}
return IDWALK_RET_NOP;
@ -3535,7 +3535,7 @@ static int read_undo_remap_noundo_data_cb(LibraryIDLinkCallbackData *cb_data)
* re-used IDs (the 'unchanged' ones), there is no guarantee that all the ID pointers they use are
* still valid.
*
* This code performs a remapping based on the session_uuid. */
* This code performs a remapping based on the session_uid. */
static void read_undo_remap_noundo_data(FileData *fd)
{
Main *new_bmain = static_cast<Main *>(fd->mainlist->first);
@ -3549,7 +3549,7 @@ static void read_undo_remap_noundo_data(FileData *fd)
}
BKE_library_foreach_ID_link(
new_bmain, id_iter, read_undo_remap_noundo_data_cb, fd->new_idmap_uuid, IDWALK_INCLUDE_UI);
new_bmain, id_iter, read_undo_remap_noundo_data_cb, fd->new_idmap_uid, IDWALK_INCLUDE_UI);
}
FOREACH_MAIN_ID_END;
}
@ -3621,10 +3621,10 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
}
if (is_undo) {
/* This idmap will store uuids of all IDs ending up in the new main, whether they are newly
/* This idmap will store uids of all IDs ending up in the new main, whether they are newly
* read, or re-used from the old main. */
fd->new_idmap_uuid = BKE_main_idmap_create(
static_cast<Main *>(fd->mainlist->first), false, nullptr, MAIN_IDMAP_TYPE_UUID);
fd->new_idmap_uid = BKE_main_idmap_create(
static_cast<Main *>(fd->mainlist->first), false, nullptr, MAIN_IDMAP_TYPE_UID);
/* Copy all 'no undo' local data from old to new bmain. */
read_undo_reuse_noundo_local_ids(fd);
@ -4858,9 +4858,9 @@ ID *BLO_read_get_new_id_address(BlendLibReader *reader,
return static_cast<ID *>(newlibadr(reader->fd, self_id, is_linked_only, id));
}
ID *BLO_read_get_new_id_address_from_session_uuid(BlendLibReader *reader, uint session_uuid)
ID *BLO_read_get_new_id_address_from_session_uid(BlendLibReader *reader, uint session_uid)
{
return BKE_main_idmap_lookup_uuid(reader->fd->new_idmap_uuid, session_uuid);
return BKE_main_idmap_lookup_uid(reader->fd->new_idmap_uid, session_uid);
}
int BLO_read_fileversion_get(BlendDataReader *reader)

View File

@ -118,11 +118,11 @@ struct FileData {
/** Used for undo. */
ListBase *old_mainlist;
/**
* IDMap using UUID's as keys of all the old IDs in the old bmain. Used during undo to find a
* IDMap using UID's as keys of all the old IDs in the old bmain. Used during undo to find a
* matching old data when reading a new ID. */
IDNameLib_Map *old_idmap_uuid;
IDNameLib_Map *old_idmap_uid;
/**
* IDMap using uuids as keys of the IDs read (or moved) in the new main(s).
* IDMap using uids as keys of the IDs read (or moved) in the new main(s).
*
* Used during undo to ensure that the ID pointers from the 'no undo' IDs remain valid (these
* IDs are re-used from old main even if their content is not the same as in the memfile undo
@ -130,7 +130,7 @@ struct FileData {
*
* Also used to find current valid pointers (or none) of these 'no undo' IDs existing in
* read memfile. */
IDNameLib_Map *new_idmap_uuid;
IDNameLib_Map *new_idmap_uid;
BlendFileReadReport *reports;
};

View File

@ -97,17 +97,17 @@ void BLO_memfile_write_init(MemFileWriteData *mem_data,
reference_memfile->chunks.first) :
nullptr;
/* If we have a reference memfile, we generate a mapping between the session_uuid's of the
/* If we have a reference memfile, we generate a mapping between the session_uid's of the
* IDs stored in that previous undo step, and its first matching memchunk. This will allow
* us to easily find the existing undo memory storage of IDs even when some re-ordering in
* current Main data-base broke the order matching with the memchunks from previous step.
*/
if (reference_memfile != nullptr) {
uint current_session_uuid = MAIN_ID_SESSION_UUID_UNSET;
uint current_session_uid = MAIN_ID_SESSION_UID_UNSET;
LISTBASE_FOREACH (MemFileChunk *, mem_chunk, &reference_memfile->chunks) {
if (!ELEM(mem_chunk->id_session_uuid, MAIN_ID_SESSION_UUID_UNSET, current_session_uuid)) {
current_session_uuid = mem_chunk->id_session_uuid;
mem_data->id_session_uuid_mapping.add_new(current_session_uuid, mem_chunk);
if (!ELEM(mem_chunk->id_session_uid, MAIN_ID_SESSION_UID_UNSET, current_session_uid)) {
current_session_uid = mem_chunk->id_session_uid;
mem_data->id_session_uid_mapping.add_new(current_session_uid, mem_chunk);
}
}
}
@ -115,7 +115,7 @@ void BLO_memfile_write_init(MemFileWriteData *mem_data,
void BLO_memfile_write_finalize(MemFileWriteData *mem_data)
{
mem_data->id_session_uuid_mapping.clear_and_shrink();
mem_data->id_session_uid_mapping.clear_and_shrink();
}
void BLO_memfile_chunk_add(MemFileWriteData *mem_data, const char *buf, size_t size)
@ -132,7 +132,7 @@ void BLO_memfile_chunk_add(MemFileWriteData *mem_data, const char *buf, size_t s
* perform an undo push may make changes after the last undo push that
* will then not be undo. Though it's not entirely clear that is wrong behavior. */
curchunk->is_identical_future = true;
curchunk->id_session_uuid = mem_data->current_id_session_uuid;
curchunk->id_session_uid = mem_data->current_id_session_uid;
BLI_addtail(&memfile->chunks, curchunk);
/* we compare compchunk with buf */

View File

@ -450,7 +450,7 @@ static void versions_gpencil_add_main(Main *bmain, ListBase *lb, ID *id, const c
/* alphabetic insertion: is in BKE_id_new_name_validate */
if ((id->tag & LIB_TAG_TEMP_MAIN) == 0) {
BKE_lib_libblock_session_uuid_ensure(id);
BKE_lib_libblock_session_uid_ensure(id);
}
if (G.debug & G_DEBUG) {

View File

@ -612,27 +612,27 @@ static bool mywrite_end(WriteData *wd)
static void mywrite_id_begin(WriteData *wd, ID *id)
{
if (wd->use_memfile) {
wd->mem.current_id_session_uuid = id->session_uuid;
wd->mem.current_id_session_uid = id->session_uid;
/* If current next memchunk does not match the ID we are about to write, or is not the _first_
* one for said ID, try to find the correct memchunk in the mapping using ID's session_uuid. */
* one for said ID, try to find the correct memchunk in the mapping using ID's session_uid. */
MemFileChunk *curr_memchunk = wd->mem.reference_current_chunk;
MemFileChunk *prev_memchunk = curr_memchunk != nullptr ?
static_cast<MemFileChunk *>(curr_memchunk->prev) :
nullptr;
if ((curr_memchunk == nullptr || curr_memchunk->id_session_uuid != id->session_uuid ||
if ((curr_memchunk == nullptr || curr_memchunk->id_session_uid != id->session_uid ||
(prev_memchunk != nullptr &&
(prev_memchunk->id_session_uuid == curr_memchunk->id_session_uuid))))
(prev_memchunk->id_session_uid == curr_memchunk->id_session_uid))))
{
if (MemFileChunk *ref = wd->mem.id_session_uuid_mapping.lookup_default(id->session_uuid,
nullptr))
if (MemFileChunk *ref = wd->mem.id_session_uid_mapping.lookup_default(id->session_uid,
nullptr))
{
wd->mem.reference_current_chunk = static_cast<MemFileChunk *>(ref);
}
/* Else, no existing memchunk found, i.e. this is supposed to be a new ID. */
}
/* Otherwise, we try with the current memchunk in any case, whether it is matching current
* ID's session_uuid or not. */
* ID's session_uid or not. */
}
}
@ -647,7 +647,7 @@ static void mywrite_id_end(WriteData *wd, ID * /*id*/)
/* Very important to do it after every ID write now, otherwise we cannot know whether a
* specific ID changed or not. */
mywrite_flush(wd);
wd->mem.current_id_session_uuid = MAIN_ID_SESSION_UUID_UNSET;
wd->mem.current_id_session_uid = MAIN_ID_SESSION_UID_UNSET;
}
}

View File

@ -150,7 +150,7 @@ DepsgraphNodeBuilder::~DepsgraphNodeBuilder()
IDNode *DepsgraphNodeBuilder::add_id_node(ID *id)
{
BLI_assert(id->session_uuid != MAIN_ID_SESSION_UUID_UNSET);
BLI_assert(id->session_uid != MAIN_ID_SESSION_UID_UNSET);
const ID_Type id_type = GS(id->name);
IDNode *id_node = nullptr;
@ -158,7 +158,7 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id)
IDComponentsMask previously_visible_components_mask = 0;
uint32_t previous_eval_flags = 0;
DEGCustomDataMeshMasks previous_customdata_masks;
IDInfo *id_info = id_info_hash_.lookup_default(id->session_uuid, nullptr);
IDInfo *id_info = id_info_hash_.lookup_default(id->session_uid, nullptr);
if (id_info != nullptr) {
id_cow = id_info->id_cow;
previously_visible_components_mask = id_info->previously_visible_components_mask;
@ -397,8 +397,8 @@ void DepsgraphNodeBuilder::begin_build()
id_info->previously_visible_components_mask = id_node->visible_components_mask;
id_info->previous_eval_flags = id_node->eval_flags;
id_info->previous_customdata_masks = id_node->customdata_masks;
BLI_assert(!id_info_hash_.contains(id_node->id_orig_session_uuid));
id_info_hash_.add_new(id_node->id_orig_session_uuid, id_info);
BLI_assert(!id_info_hash_.contains(id_node->id_orig_session_uid));
id_info_hash_.add_new(id_node->id_orig_session_uid, id_info);
id_node->id_cow = nullptr;
}

View File

@ -322,7 +322,7 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
* very root is visible (aka not restricted.). */
bool is_parent_collection_visible_;
/* Indexed by original ID.session_uuid, values are IDInfo. */
/* Indexed by original ID.session_uid, values are IDInfo. */
Map<uint, IDInfo *> id_info_hash_;
/* Set of IDs which were already build. Makes it easier to keep track of

View File

@ -270,11 +270,11 @@ bool id_copy_inplace_no_main(const ID *id, ID *newid)
{
const ID *id_for_copy = id;
if (G.debug & G_DEBUG_DEPSGRAPH_UUID) {
if (G.debug & G_DEBUG_DEPSGRAPH_UID) {
const ID_Type id_type = GS(id_for_copy->name);
if (id_type == ID_OB) {
const Object *object = reinterpret_cast<const Object *>(id_for_copy);
BKE_object_check_uuids_unique_and_report(object);
BKE_object_check_uids_unique_and_report(object);
}
}
@ -303,8 +303,8 @@ bool id_copy_inplace_no_main(const ID *id, ID *newid)
bool scene_copy_inplace_no_main(const Scene *scene, Scene *new_scene)
{
if (G.debug & G_DEBUG_DEPSGRAPH_UUID) {
SEQ_relations_check_uuids_unique_and_report(scene);
if (G.debug & G_DEBUG_DEPSGRAPH_UID) {
SEQ_relations_check_uids_unique_and_report(scene);
}
#ifdef NESTED_ID_NASTY_WORKAROUND

View File

@ -58,10 +58,10 @@ void ObjectRuntimeBackup::backup_modifier_runtime_data(Object *object)
continue;
}
const SessionUUID &session_uuid = modifier_data->session_uuid;
BLI_assert(BLI_session_uuid_is_generated(&session_uuid));
const SessionUID &session_uid = modifier_data->session_uid;
BLI_assert(BLI_session_uid_is_generated(&session_uid));
modifier_runtime_data.add(session_uuid, ModifierDataBackup(modifier_data));
modifier_runtime_data.add(session_uid, ModifierDataBackup(modifier_data));
modifier_data->runtime = nullptr;
}
}
@ -70,10 +70,10 @@ void ObjectRuntimeBackup::backup_pose_channel_runtime_data(Object *object)
{
if (object->pose != nullptr) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) {
const SessionUUID &session_uuid = pchan->runtime.session_uuid;
BLI_assert(BLI_session_uuid_is_generated(&session_uuid));
const SessionUID &session_uid = pchan->runtime.session_uid;
BLI_assert(BLI_session_uid_is_generated(&session_uid));
pose_channel_runtime_data.add(session_uuid, pchan->runtime);
pose_channel_runtime_data.add(session_uid, pchan->runtime);
BKE_pose_channel_runtime_reset(&pchan->runtime);
}
}
@ -149,10 +149,10 @@ void ObjectRuntimeBackup::restore_to_object(Object *object)
void ObjectRuntimeBackup::restore_modifier_runtime_data(Object *object)
{
LISTBASE_FOREACH (ModifierData *, modifier_data, &object->modifiers) {
const SessionUUID &session_uuid = modifier_data->session_uuid;
BLI_assert(BLI_session_uuid_is_generated(&session_uuid));
const SessionUID &session_uid = modifier_data->session_uid;
BLI_assert(BLI_session_uid_is_generated(&session_uid));
optional<ModifierDataBackup> backup = modifier_runtime_data.pop_try(session_uuid);
optional<ModifierDataBackup> backup = modifier_runtime_data.pop_try(session_uid);
if (backup.has_value()) {
modifier_data->runtime = backup->runtime;
}
@ -178,8 +178,8 @@ void ObjectRuntimeBackup::restore_pose_channel_runtime_data(Object *object)
{
if (object->pose != nullptr) {
LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) {
const SessionUUID &session_uuid = pchan->runtime.session_uuid;
optional<bPoseChannel_Runtime> runtime = pose_channel_runtime_data.pop_try(session_uuid);
const SessionUID &session_uid = pchan->runtime.session_uid;
optional<bPoseChannel_Runtime> runtime = pose_channel_runtime_data.pop_try(session_uid);
if (runtime.has_value()) {
pchan->runtime = *runtime;
}

View File

@ -9,11 +9,11 @@
#pragma once
#include "DNA_object_types.h"
#include "DNA_session_uuid_types.h"
#include "DNA_session_uid_types.h"
#include "BKE_object_types.hh"
#include "BLI_session_uuid.h"
#include "BLI_session_uid.h"
#include "intern/depsgraph_type.hh"
#include "intern/eval/deg_eval_runtime_backup_modifier.h"
@ -46,8 +46,8 @@ class ObjectRuntimeBackup {
optional<LightLinkingRuntime> light_linking_runtime;
short base_flag;
unsigned short base_local_view_bits;
Map<SessionUUID, ModifierDataBackup> modifier_runtime_data;
Map<SessionUUID, bPoseChannel_Runtime> pose_channel_runtime_data;
Map<SessionUID, ModifierDataBackup> modifier_runtime_data;
Map<SessionUID, bPoseChannel_Runtime> pose_channel_runtime_data;
};
} // namespace blender::deg

View File

@ -27,9 +27,9 @@ static bool seq_init_cb(Sequence *seq, void *user_data)
SequenceBackup sequence_backup(sb->depsgraph);
sequence_backup.init_from_sequence(seq);
if (!sequence_backup.isEmpty()) {
const SessionUUID &session_uuid = seq->runtime.session_uuid;
BLI_assert(BLI_session_uuid_is_generated(&session_uuid));
sb->sequences_backup.add(session_uuid, sequence_backup);
const SessionUID &session_uid = seq->runtime.session_uid;
BLI_assert(BLI_session_uid_is_generated(&session_uid));
sb->sequences_backup.add(session_uid, sequence_backup);
}
return true;
}
@ -44,9 +44,9 @@ void SequencerBackup::init_from_scene(Scene *scene)
static bool seq_restore_cb(Sequence *seq, void *user_data)
{
SequencerBackup *sb = (SequencerBackup *)user_data;
const SessionUUID &session_uuid = seq->runtime.session_uuid;
BLI_assert(BLI_session_uuid_is_generated(&session_uuid));
SequenceBackup *sequence_backup = sb->sequences_backup.lookup_ptr(session_uuid);
const SessionUID &session_uid = seq->runtime.session_uid;
BLI_assert(BLI_session_uid_is_generated(&session_uid));
SequenceBackup *sequence_backup = sb->sequences_backup.lookup_ptr(session_uid);
if (sequence_backup != nullptr) {
sequence_backup->restore_to_sequence(seq);
}

View File

@ -8,9 +8,9 @@
#pragma once
#include "DNA_session_uuid_types.h"
#include "DNA_session_uid_types.h"
#include "BLI_session_uuid.h"
#include "BLI_session_uid.h"
#include "intern/depsgraph_type.hh"
#include "intern/eval/deg_eval_runtime_backup_sequence.h"
@ -31,7 +31,7 @@ class SequencerBackup {
const Depsgraph *depsgraph;
Map<SessionUUID, SequenceBackup> sequences_backup;
Map<SessionUID, SequenceBackup> sequences_backup;
};
} // namespace blender::deg

View File

@ -62,7 +62,7 @@ void IDNode::init(const ID *id, const char * /*subdata*/)
/* Store ID-pointer. */
id_type = GS(id->name);
id_orig = (ID *)id;
id_orig_session_uuid = id->session_uuid;
id_orig_session_uid = id->session_uid;
eval_flags = 0;
previous_eval_flags = 0;
customdata_masks = DEGCustomDataMeshMasks();

View File

@ -71,7 +71,7 @@ struct IDNode : public Node {
* Is used on relations update to map evaluated state from old nodes to the new ones, without
* relying on pointers (which are not guaranteed to be unique) and without dereferencing id_orig
* which could be "stale" pointer. */
uint id_orig_session_uuid;
uint id_orig_session_uid;
/* Evaluated data-block.
* Will be covered by the copy-on-write system if the ID Type needs it. */

View File

@ -85,7 +85,7 @@ static const bNodeTree *get_asset_or_local_node_group(const bContext &C,
{
Main &bmain = *CTX_data_main(&C);
if (bNodeTree *group = reinterpret_cast<bNodeTree *>(
WM_operator_properties_id_lookup_from_name_or_session_uuid(&bmain, &ptr, ID_NT)))
WM_operator_properties_id_lookup_from_name_or_session_uid(&bmain, &ptr, ID_NT)))
{
return group;
}

View File

@ -93,7 +93,7 @@ static bool ui_drop_material_poll(bContext *C, wmDrag *drag, const wmEvent * /*e
static void ui_drop_material_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
{
const ID *id = WM_drag_get_local_ID_or_import_from_asset(C, drag, ID_MA);
RNA_int_set(drop->ptr, "session_uuid", int(id->session_uuid));
RNA_int_set(drop->ptr, "session_uid", int(id->session_uid));
}
static std::string ui_drop_material_tooltip(bContext *C,

View File

@ -2572,7 +2572,7 @@ static int ui_drop_material_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Material *ma = (Material *)WM_operator_properties_id_lookup_from_name_or_session_uuid(
Material *ma = (Material *)WM_operator_properties_id_lookup_from_name_or_session_uid(
bmain, op->ptr, ID_MA);
if (ma == nullptr) {
return OPERATOR_CANCELLED;

View File

@ -680,13 +680,13 @@ static void um_arraystore_free(UndoMesh *um)
*/
static UndoMesh **mesh_undostep_reference_elems_from_objects(Object **object, int object_len)
{
/* Map: `Mesh.id.session_uuid` -> `UndoMesh`. */
/* Map: `Mesh.id.session_uid` -> `UndoMesh`. */
GHash *uuid_map = BLI_ghash_ptr_new_ex(__func__, object_len);
UndoMesh **um_references = static_cast<UndoMesh **>(
MEM_callocN(sizeof(UndoMesh *) * object_len, __func__));
for (int i = 0; i < object_len; i++) {
const Mesh *mesh = static_cast<const Mesh *>(object[i]->data);
BLI_ghash_insert(uuid_map, POINTER_FROM_INT(mesh->id.session_uuid), &um_references[i]);
BLI_ghash_insert(uuid_map, POINTER_FROM_INT(mesh->id.session_uid), &um_references[i]);
}
int uuid_map_len = object_len;
@ -696,8 +696,8 @@ static UndoMesh **mesh_undostep_reference_elems_from_objects(Object **object, in
UndoMesh *um_iter = static_cast<UndoMesh *>(um_arraystore.local_links.last);
while (um_iter && (uuid_map_len != 0)) {
UndoMesh **um_p;
if ((um_p = static_cast<UndoMesh **>(BLI_ghash_popkey(
uuid_map, POINTER_FROM_INT(um_iter->mesh.id.session_uuid), nullptr))))
if ((um_p = static_cast<UndoMesh **>(
BLI_ghash_popkey(uuid_map, POINTER_FROM_INT(um_iter->mesh.id.session_uid), nullptr))))
{
*um_p = um_iter;
uuid_map_len--;
@ -957,7 +957,7 @@ static bool mesh_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p)
#ifdef USE_ARRAY_STORE
/** As this is only data storage it is safe to set the session ID here. */
elem->data.mesh.id.session_uuid = mesh->id.session_uuid;
elem->data.mesh.id.session_uid = mesh->id.session_uid;
#endif
}
MEM_freeN(objects);

View File

@ -262,7 +262,7 @@ static bNodeTree *get_asset_or_local_node_group(const bContext &C,
{
Main &bmain = *CTX_data_main(&C);
if (bNodeTree *group = reinterpret_cast<bNodeTree *>(
WM_operator_properties_id_lookup_from_name_or_session_uuid(&bmain, &ptr, ID_NT)))
WM_operator_properties_id_lookup_from_name_or_session_uid(&bmain, &ptr, ID_NT)))
{
return group;
}

View File

@ -1809,7 +1809,7 @@ static std::optional<CollectionAddInfo> collection_add_info_get_from_op(bContext
PropertyRNA *prop_location = RNA_struct_find_property(op->ptr, "location");
add_info.collection = reinterpret_cast<Collection *>(
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_GR));
WM_operator_properties_id_lookup_from_name_or_session_uid(bmain, op->ptr, ID_GR));
bool update_location_if_necessary = false;
if (add_info.collection) {
@ -2055,8 +2055,7 @@ static int object_data_instance_add_exec(bContext *C, wmOperator *op)
PropertyRNA *prop_location = RNA_struct_find_property(op->ptr, "location");
const short id_type = RNA_property_enum_get(op->ptr, prop_type);
id = WM_operator_properties_id_lookup_from_name_or_session_uuid(
bmain, op->ptr, (ID_Type)id_type);
id = WM_operator_properties_id_lookup_from_name_or_session_uid(bmain, op->ptr, (ID_Type)id_type);
if (id == nullptr) {
return OPERATOR_CANCELLED;
}
@ -4055,7 +4054,7 @@ static int object_add_named_exec(bContext *C, wmOperator *op)
/* Find object, create fake base. */
Object *ob = reinterpret_cast<Object *>(
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_OB));
WM_operator_properties_id_lookup_from_name_or_session_uid(bmain, op->ptr, ID_OB));
if (ob == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Object not found");
@ -4169,7 +4168,7 @@ static int object_transform_to_mouse_exec(bContext *C, wmOperator *op)
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = reinterpret_cast<Object *>(
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_OB));
WM_operator_properties_id_lookup_from_name_or_session_uid(bmain, op->ptr, ID_OB));
if (!ob) {
BKE_view_layer_synced_ensure(scene, view_layer);
@ -4257,10 +4256,10 @@ void OBJECT_OT_transform_to_mouse(wmOperatorType *ot)
nullptr,
MAX_ID_NAME - 2,
"Name",
"Object name to place (uses the active object when this and 'session_uuid' are unset)");
"Object name to place (uses the active object when this and 'session_uid' are unset)");
RNA_def_property_flag(prop, (PropertyFlag)(PROP_SKIP_SAVE | PROP_HIDDEN));
prop = RNA_def_int(ot->srna,
"session_uuid",
"session_uid",
0,
INT32_MIN,
INT32_MAX,

View File

@ -778,7 +778,7 @@ static Vector<NodeBakeRequest> bake_single_node_gather_bake_request(bContext *C,
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *object = reinterpret_cast<Object *>(
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_OB));
WM_operator_properties_id_lookup_from_name_or_session_uid(bmain, op->ptr, ID_OB));
if (object == nullptr) {
return {};
}
@ -890,7 +890,7 @@ static int delete_single_bake_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Object *object = reinterpret_cast<Object *>(
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_OB));
WM_operator_properties_id_lookup_from_name_or_session_uid(bmain, op->ptr, ID_OB));
if (object == nullptr) {
return OPERATOR_CANCELLED;
}

View File

@ -2384,8 +2384,8 @@ static int make_override_library_exec(bContext *C, wmOperator *op)
}
else if (!make_override_library_object_overridable_check(bmain, obact)) {
const int i = RNA_property_int_get(op->ptr, op->type->prop);
const uint collection_session_uuid = *((const uint *)&i);
if (collection_session_uuid == MAIN_ID_SESSION_UUID_UNSET) {
const uint collection_session_uid = *((const uint *)&i);
if (collection_session_uid == MAIN_ID_SESSION_UID_UNSET) {
BKE_reportf(op->reports,
RPT_ERROR_INVALID_INPUT,
"Could not find an overridable root hierarchy for object '%s'",
@ -2394,9 +2394,9 @@ static int make_override_library_exec(bContext *C, wmOperator *op)
}
Collection *collection = static_cast<Collection *>(
BLI_listbase_bytes_find(&bmain->collections,
&collection_session_uuid,
sizeof(collection_session_uuid),
offsetof(ID, session_uuid)));
&collection_session_uid,
sizeof(collection_session_uid),
offsetof(ID, session_uid)));
id_root = &collection->id;
user_overrides_from_selected_objects = true;
}
@ -2441,7 +2441,7 @@ static int make_override_library_exec(bContext *C, wmOperator *op)
else if (user_overrides_from_selected_objects) {
/* Only selected objects can be 'user overrides'. */
FOREACH_SELECTED_OBJECT_BEGIN (view_layer, CTX_wm_view3d(C), ob_iter) {
BLI_gset_add(user_overrides_objects_uids, POINTER_FROM_UINT(ob_iter->id.session_uuid));
BLI_gset_add(user_overrides_objects_uids, POINTER_FROM_UINT(ob_iter->id.session_uid));
}
FOREACH_SELECTED_OBJECT_END;
}
@ -2449,7 +2449,7 @@ static int make_override_library_exec(bContext *C, wmOperator *op)
/* Only armatures inside the root collection (and their children) can be 'user overrides'. */
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN ((Collection *)id_root, ob_iter) {
if (ob_iter->type == OB_ARMATURE) {
BLI_gset_add(user_overrides_objects_uids, POINTER_FROM_UINT(ob_iter->id.session_uuid));
BLI_gset_add(user_overrides_objects_uids, POINTER_FROM_UINT(ob_iter->id.session_uid));
}
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
@ -2467,7 +2467,7 @@ static int make_override_library_exec(bContext *C, wmOperator *op)
}
LISTBASE_FOREACH (CollectionObject *, coll_ob_iter, &coll_iter->gobject) {
if (BLI_gset_haskey(user_overrides_objects_uids,
POINTER_FROM_UINT(coll_ob_iter->ob->id.session_uuid)))
POINTER_FROM_UINT(coll_ob_iter->ob->id.session_uid)))
{
/* Tag for remapping when creating overrides. */
coll_iter->id.tag |= LIB_TAG_DOIT;
@ -2499,7 +2499,7 @@ static int make_override_library_exec(bContext *C, wmOperator *op)
continue;
}
if (BLI_gset_haskey(user_overrides_objects_uids,
POINTER_FROM_UINT(id_iter->override_library->reference->session_uuid)))
POINTER_FROM_UINT(id_iter->override_library->reference->session_uid)))
{
id_iter->override_library->flag &= ~LIBOVERRIDE_FLAG_SYSTEM_DEFINED;
}
@ -2627,12 +2627,12 @@ static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEve
}
if (potential_root_collections.is_empty()) {
RNA_property_int_set(op->ptr, op->type->prop, MAIN_ID_SESSION_UUID_UNSET);
RNA_property_int_set(op->ptr, op->type->prop, MAIN_ID_SESSION_UID_UNSET);
return make_override_library_exec(C, op);
}
if (potential_root_collections.size() == 1) {
Collection *collection_root = potential_root_collections.pop();
RNA_property_int_set(op->ptr, op->type->prop, *((int *)&collection_root->id.session_uuid));
RNA_property_int_set(op->ptr, op->type->prop, *((int *)&collection_root->id.session_uid));
return make_override_library_exec(C, op);
}
@ -2677,11 +2677,11 @@ void OBJECT_OT_make_override_library(wmOperatorType *ot)
PropertyRNA *prop;
prop = RNA_def_int(ot->srna,
"collection",
MAIN_ID_SESSION_UUID_UNSET,
MAIN_ID_SESSION_UID_UNSET,
INT_MIN,
INT_MAX,
"Override Collection",
"Session UUID of the directly linked collection containing the selected "
"Session UID of the directly linked collection containing the selected "
"object, to make an override from",
INT_MIN,
INT_MAX);
@ -2957,7 +2957,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent
Object *ob = ED_view3d_give_material_slot_under_cursor(C, event->mval, &mat_slot);
mat_slot = max_ii(mat_slot, 1);
Material *ma = (Material *)WM_operator_properties_id_lookup_from_name_or_session_uuid(
Material *ma = (Material *)WM_operator_properties_id_lookup_from_name_or_session_uid(
bmain, op->ptr, ID_MA);
if (ob == nullptr || ma == nullptr) {
@ -3007,8 +3007,8 @@ std::string ED_object_ot_drop_geometry_nodes_tooltip(bContext *C,
return {};
}
const uint32_t session_uuid = RNA_int_get(properties, "session_uuid");
const ID *id = BKE_libblock_find_session_uuid(CTX_data_main(C), ID_NT, session_uuid);
const uint32_t session_uid = RNA_int_get(properties, "session_uid");
const ID *id = BKE_libblock_find_session_uid(CTX_data_main(C), ID_NT, session_uid);
if (!id) {
return {};
}
@ -3046,8 +3046,8 @@ static int drop_geometry_nodes_invoke(bContext *C, wmOperator *op, const wmEvent
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
const uint32_t uuid = RNA_int_get(op->ptr, "session_uuid");
bNodeTree *node_tree = (bNodeTree *)BKE_libblock_find_session_uuid(bmain, ID_NT, uuid);
const uint32_t uid = RNA_int_get(op->ptr, "session_uid");
bNodeTree *node_tree = (bNodeTree *)BKE_libblock_find_session_uid(bmain, ID_NT, uid);
if (!node_tree) {
return OPERATOR_CANCELLED;
}
@ -3092,12 +3092,12 @@ void OBJECT_OT_drop_geometry_nodes(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
PropertyRNA *prop = RNA_def_int(ot->srna,
"session_uuid",
"session_uid",
0,
INT32_MIN,
INT32_MAX,
"Session UUID",
"Session UUID of the geometry node group being dropped",
"Session UID",
"Session UID of the geometry node group being dropped",
INT32_MIN,
INT32_MAX);
RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE));

View File

@ -292,7 +292,7 @@ static int node_add_group_exec(bContext *C, wmOperator *op)
bNodeTree *ntree = snode->edittree;
bNodeTree *node_group = reinterpret_cast<bNodeTree *>(
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_NT));
WM_operator_properties_id_lookup_from_name_or_session_uid(bmain, op->ptr, ID_NT));
if (!node_group) {
return OPERATOR_CANCELLED;
}
@ -511,7 +511,7 @@ static int node_add_object_exec(bContext *C, wmOperator *op)
bNodeTree *ntree = snode->edittree;
Object *object = reinterpret_cast<Object *>(
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_OB));
WM_operator_properties_id_lookup_from_name_or_session_uid(bmain, op->ptr, ID_OB));
if (!object) {
return OPERATOR_CANCELLED;
@ -597,7 +597,7 @@ static int node_add_collection_exec(bContext *C, wmOperator *op)
bNodeTree &ntree = *snode.edittree;
Collection *collection = reinterpret_cast<Collection *>(
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_GR));
WM_operator_properties_id_lookup_from_name_or_session_uid(bmain, op->ptr, ID_GR));
if (!collection) {
return OPERATOR_CANCELLED;
@ -808,7 +808,7 @@ static int node_add_mask_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
SpaceNode &snode = *CTX_wm_space_node(C);
ID *mask = WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_MSK);
ID *mask = WM_operator_properties_id_lookup_from_name_or_session_uid(bmain, op->ptr, ID_MSK);
if (!mask) {
return OPERATOR_CANCELLED;
}
@ -861,7 +861,7 @@ static int node_add_material_exec(bContext *C, wmOperator *op)
bNodeTree *ntree = snode->edittree;
Material *material = reinterpret_cast<Material *>(
WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_MA));
WM_operator_properties_id_lookup_from_name_or_session_uid(bmain, op->ptr, ID_MA));
if (!material) {
return OPERATOR_CANCELLED;

View File

@ -907,7 +907,7 @@ static void node_group_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
{
ID *id = WM_drag_get_local_ID_or_import_from_asset(C, drag, 0);
RNA_int_set(drop->ptr, "session_uuid", int(id->session_uuid));
RNA_int_set(drop->ptr, "session_uid", int(id->session_uid));
RNA_boolean_set(drop->ptr, "show_datablock_in_node", (drag->type != WM_DRAG_ASSET));
}
@ -916,7 +916,7 @@ static void node_id_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
{
ID *id = WM_drag_get_local_ID_or_import_from_asset(C, drag, 0);
RNA_int_set(drop->ptr, "session_uuid", int(id->session_uuid));
RNA_int_set(drop->ptr, "session_uid", int(id->session_uid));
}
static void node_id_path_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
@ -924,7 +924,7 @@ static void node_id_path_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
ID *id = WM_drag_get_local_ID_or_import_from_asset(C, drag, 0);
if (id) {
RNA_int_set(drop->ptr, "session_uuid", int(id->session_uuid));
RNA_int_set(drop->ptr, "session_uid", int(id->session_uid));
RNA_struct_property_unset(drop->ptr, "filepath");
return;
}

View File

@ -1964,8 +1964,8 @@ static bool outliner_but_identity_cmp_context_id_fn(const uiBut *a, const uiBut
const ID *id_a = (const ID *)idptr_a->data;
const ID *id_b = (const ID *)idptr_b->data;
/* Using session UUID to compare is safer than using the pointer. */
return id_a->session_uuid == id_b->session_uuid;
/* Using session UID to compare is safer than using the pointer. */
return id_a->session_uid == id_b->session_uid;
}
static void outliner_draw_overrides_restrictbuts(Main *bmain,

View File

@ -1056,7 +1056,7 @@ struct OutlinerLibOverrideData {
* solving broken overrides while not losing *all* of your overrides. */
bool do_resync_hierarchy_enforce;
/** A set of the selected tree elements' ID 'uuid'. Used to clear 'system override' flags on
/** A set of the selected tree elements' ID 'uid'. Used to clear 'system override' flags on
* their newly-created liboverrides in post-process step of override hierarchy creation. */
Set<uint> selected_id_uid;
@ -1067,7 +1067,7 @@ struct OutlinerLibOverrideData {
* override), or an actual already existing override. */
Map<ID *, Vector<OutlinerLiboverrideDataIDRoot>> id_hierarchy_roots;
/** All 'session_uuid' of all hierarchy root IDs used or created by the operation. */
/** All 'session_uid' of all hierarchy root IDs used or created by the operation. */
Set<uint> id_hierarchy_roots_uid;
void id_root_add(ID *id_hierarchy_root_reference,
@ -1125,10 +1125,10 @@ static void id_override_library_create_hierarchy_pre_process_fn(bContext *C,
/* Only process a given ID once. Otherwise, all kind of weird things can happen if e.g. a
* selected sub-collection is part of more than one override hierarchies. */
if (data->selected_id_uid.contains(id_root_reference->session_uuid)) {
if (data->selected_id_uid.contains(id_root_reference->session_uid)) {
return;
}
data->selected_id_uid.add(id_root_reference->session_uuid);
data->selected_id_uid.add(id_root_reference->session_uid);
if (ID_IS_OVERRIDE_LIBRARY_REAL(id_root_reference) && !ID_IS_LINKED(id_root_reference)) {
id_root_reference->override_library->flag &= ~LIBOVERRIDE_FLAG_SYSTEM_DEFINED;
@ -1157,7 +1157,7 @@ static void id_override_library_create_hierarchy_pre_process_fn(bContext *C,
Collection *root_collection = reinterpret_cast<Collection *>(id_root_reference);
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (root_collection, object_iter) {
if (id_root_reference->lib == object_iter->id.lib && object_iter->type == OB_ARMATURE) {
data->selected_id_uid.add(object_iter->id.session_uuid);
data->selected_id_uid.add(object_iter->id.session_uid);
}
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
@ -1357,7 +1357,7 @@ static void id_override_library_create_hierarchy(
BLI_assert(id_hierarchy_root_override == id_hierarchy_root_reference);
}
data_idroot.id_hierarchy_root_override = id_hierarchy_root_override;
data.id_hierarchy_roots_uid.add(id_hierarchy_root_override->session_uuid);
data.id_hierarchy_roots_uid.add(id_hierarchy_root_override->session_uid);
}
}
else if (ID_IS_OVERRIDABLE_LIBRARY(data_idroot.id_root_reference)) {
@ -1423,12 +1423,12 @@ static void id_override_library_create_hierarchy_process(bContext *C,
}
if (id_iter->override_library->hierarchy_root != nullptr &&
!data.id_hierarchy_roots_uid.contains(
id_iter->override_library->hierarchy_root->session_uuid))
id_iter->override_library->hierarchy_root->session_uid))
{
continue;
}
if (data.selected_id_uid.contains(id_iter->override_library->reference->session_uuid) ||
data.selected_id_uid.contains(id_iter->session_uuid))
if (data.selected_id_uid.contains(id_iter->override_library->reference->session_uid) ||
data.selected_id_uid.contains(id_iter->session_uid))
{
id_iter->override_library->flag &= ~LIBOVERRIDE_FLAG_SYSTEM_DEFINED;
}

View File

@ -350,7 +350,7 @@ int sequencer_clipboard_paste_exec(bContext *C, wmOperator *op)
ListBase nseqbase = {nullptr, nullptr};
/* NOTE: SEQ_sequence_base_dupli_recursive() takes care of generating
* new UUIDs for sequences in the new list. */
* new UIDs for sequences in the new list. */
SEQ_sequence_base_dupli_recursive(
scene_src, scene_dst, &nseqbase, &scene_src->ed->seqbase, 0, 0);

View File

@ -1605,7 +1605,7 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator * /*op*/)
Sequence *seq = static_cast<Sequence *>(duplicated_strips.first);
/* Rely on the `duplicated_strips` list being added at the end.
* Their UUIDs has been re-generated by the #SEQ_sequence_base_dupli_recursive(). */
* Their UIDs has been re-generated by the #SEQ_sequence_base_dupli_recursive(). */
BLI_movelisttolist(ed->seqbasep, &duplicated_strips);
/* Handle duplicated strips: set active, select, ensure unique name and duplicate animation
@ -2004,7 +2004,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
Sequence *seqm = SEQ_sequence_alloc(active_seqbase, 1, 1, SEQ_TYPE_META);
/* Remove all selected from main list, and put in meta.
* Sequence is moved within the same edit, no need to re-generate the UUID. */
* Sequence is moved within the same edit, no need to re-generate the UID. */
LISTBASE_FOREACH_MUTABLE (Sequence *, seq, active_seqbase) {
if (seq != seqm && seq->flag & SELECT) {
BLI_remlink(active_seqbase, seq);
@ -2070,7 +2070,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator * /*op*/)
}
/* Remove all selected from meta, and put in main list.
* Sequence is moved within the same edit, no need to re-generate the UUID. */
* Sequence is moved within the same edit, no need to re-generate the UID. */
BLI_movelisttolist(ed->seqbasep, &active_seq->seqbase);
BLI_listbase_clear(&active_seq->seqbase);

View File

@ -715,9 +715,9 @@ static bool view3d_geometry_nodes_drop_poll(bContext *C, wmDrag *drag, const wmE
return false;
}
if (wmDropBox *drop_box = drag->drop_state.active_dropbox) {
const uint32_t uuid = RNA_int_get(drop_box->ptr, "session_uuid");
const uint32_t uid = RNA_int_get(drop_box->ptr, "session_uid");
const bNodeTree *node_tree = reinterpret_cast<const bNodeTree *>(
BKE_libblock_find_session_uuid(CTX_data_main(C), ID_NT, uuid));
BKE_libblock_find_session_uid(CTX_data_main(C), ID_NT, uid));
if (node_tree) {
return node_tree->type == NTREE_GEOMETRY;
}
@ -763,7 +763,7 @@ static void view3d_ob_drop_copy_local_id(bContext * /*C*/, wmDrag *drag, wmDropB
{
ID *id = WM_drag_get_local_ID(drag, ID_OB);
RNA_int_set(drop->ptr, "session_uuid", id->session_uuid);
RNA_int_set(drop->ptr, "session_uid", id->session_uid);
/* Don't duplicate ID's which were just imported. Only do that for existing, local IDs. */
BLI_assert(drag->type != WM_DRAG_ASSET);
@ -797,7 +797,7 @@ static void view3d_ob_drop_copy_external_asset(bContext *C, wmDrag *drag, wmDrop
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);
RNA_int_set(drop->ptr, "session_uuid", id->session_uuid);
RNA_int_set(drop->ptr, "session_uid", id->session_uid);
BKE_view_layer_synced_ensure(scene, view_layer);
Base *base = BKE_view_layer_base_find(view_layer, (Object *)id);
@ -821,7 +821,7 @@ static void view3d_ob_drop_copy_external_asset(bContext *C, wmDrag *drag, wmDrop
static void view3d_collection_drop_copy_local_id(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
{
ID *id = WM_drag_get_local_ID(drag, ID_GR);
RNA_int_set(drop->ptr, "session_uuid", int(id->session_uuid));
RNA_int_set(drop->ptr, "session_uid", int(id->session_uid));
}
/* Mostly the same logic as #view3d_ob_drop_copy_external_asset(), just different enough to make
@ -843,7 +843,7 @@ static void view3d_collection_drop_copy_external_asset(bContext *C, wmDrag *drag
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);
RNA_int_set(drop->ptr, "session_uuid", int(id->session_uuid));
RNA_int_set(drop->ptr, "session_uid", int(id->session_uid));
/* Make an object active, just use the first one in the collection. */
CollectionObject *cobject = static_cast<CollectionObject *>(collection->gobject.first);

View File

@ -692,7 +692,7 @@ static int drop_world_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
World *world = (World *)WM_operator_properties_id_lookup_from_name_or_session_uuid(
World *world = (World *)WM_operator_properties_id_lookup_from_name_or_session_uid(
bmain, op->ptr, ID_WO);
if (world == nullptr) {
return OPERATOR_CANCELLED;

View File

@ -375,7 +375,7 @@ void ED_undosys_stack_memfile_id_changed_tag(UndoStack *ustack, ID *id)
MemFile *memfile = &((MemFileUndoStep *)us)->data->memfile;
LISTBASE_FOREACH (MemFileChunk *, mem_chunk, &memfile->chunks) {
if (mem_chunk->id_session_uuid == id->session_uuid) {
if (mem_chunk->id_session_uid == id->session_uid) {
mem_chunk->is_identical_future = false;
break;
}

View File

@ -493,7 +493,7 @@ typedef struct ID {
* A session-wide unique identifier for a given ID, that remain the same across potential
* re-allocations (e.g. due to undo/redo steps).
*/
unsigned int session_uuid;
unsigned int session_uid;
IDProperty *properties;
@ -914,7 +914,7 @@ enum {
* processing, because it is a 'NO_UNDO' type of ID.
*
* \note: Also means that such ID does not need to be lib-linked during undo readfile process. It
* does need to be relinked in a different way however, doing a `session_uuid`-based lookup into
* does need to be relinked in a different way however, doing a `session_uid`-based lookup into
* the newly read main database.
*
* RESET_AFTER_USE
@ -941,7 +941,7 @@ enum {
* RESET_NEVER
*
* Don't allow assigning this to non-temporary members (since it's likely to cause errors).
* When set #ID.session_uuid isn't initialized, since the data isn't part of the session.
* When set #ID.session_uid isn't initialized, since the data isn't part of the session.
*/
LIB_TAG_TEMP_MAIN = 1 << 20,
/** General ID management info, for freeing or copying behavior e.g. */

View File

@ -15,7 +15,7 @@
#include "DNA_ID.h"
#include "DNA_armature_types.h"
#include "DNA_listBase.h"
#include "DNA_session_uuid_types.h"
#include "DNA_session_uid_types.h"
#include "DNA_userdef_types.h" /* ThemeWireColor */
#include "DNA_vec_types.h"
#include "DNA_view2d_types.h"
@ -197,7 +197,7 @@ typedef struct bPoseChannel_BBoneSegmentBoundary {
} bPoseChannel_BBoneSegmentBoundary;
typedef struct bPoseChannel_Runtime {
SessionUUID session_uuid;
SessionUID session_uid;
/* Cached dual quaternion for deformation. */
struct DualQuat deform_dual_quat;

View File

@ -11,7 +11,7 @@
#include "DNA_ID.h"
#include "DNA_customdata_types.h"
#include "DNA_defs.h"
#include "DNA_session_uuid_types.h"
#include "DNA_session_uid_types.h"
/** Workaround to forward-declare C++ type in C header. */
#ifdef __cplusplus

View File

@ -12,7 +12,7 @@
#include "DNA_defs.h"
#include "DNA_listBase.h"
#include "DNA_session_uuid_types.h"
#include "DNA_session_uid_types.h"
#ifdef __cplusplus
namespace blender {
@ -138,7 +138,7 @@ typedef struct ModifierData {
char *error;
/** Runtime field which contains unique identifier of the modifier. */
SessionUUID session_uuid;
SessionUID session_uid;
/** Runtime field which contains runtime data which is specific to a modifier type. */
void *runtime;

View File

@ -18,8 +18,8 @@
#include "DNA_color_types.h"
#include "DNA_defs.h"
#include "DNA_listBase.h"
#include "DNA_session_uuid_types.h" /* for #SessionUUID */
#include "DNA_vec_types.h" /* for #rctf */
#include "DNA_session_uid_types.h" /* for #SessionUID */
#include "DNA_vec_types.h" /* for #rctf */
struct Ipo;
struct MovieClip;
@ -139,7 +139,7 @@ typedef struct SeqRetimingKey {
} SeqRetimingKey;
typedef struct SequenceRuntime {
SessionUUID session_uuid;
SessionUID session_uid;
} SequenceRuntime;
/**

View File

@ -17,10 +17,10 @@
* - It allows to add more bits, more than standard fixed-size types can store. For example, if
* we ever need to go 128 bits, it is as simple as adding extra 64bit field.
*/
typedef struct SessionUUID {
typedef struct SessionUID {
/**
* Never access directly, as it might cause a headache when more bits are needed: if the field
* is used directly it will not be easy to find all places where partial access is used.
*/
uint64_t uuid_;
} SessionUUID;
uint64_t uid_;
} SessionUID;

View File

@ -2196,7 +2196,6 @@ static void rna_def_ID(BlenderRNA *brna)
RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE);
prop = RNA_def_property(srna, "session_uid", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, nullptr, "session_uuid");
RNA_def_property_ui_text(
prop,
"Session UID",

View File

@ -1565,7 +1565,7 @@ static NodesModifierData *get_modifier_data(Main &bmain,
return nullptr;
}
const Object *object = (Object *)BKE_libblock_find_session_uuid(
const Object *object = (Object *)BKE_libblock_find_session_uid(
&bmain, ID_OB, data.object_session_uid);
if (object == nullptr) {
return nullptr;
@ -1702,7 +1702,7 @@ static void add_attribute_search_button(const bContext &C,
}
AttributeSearchData *data = MEM_new<AttributeSearchData>(__func__);
data->object_session_uid = object->id.session_uuid;
data->object_session_uid = object->id.session_uid;
STRNCPY(data->modifier_name, nmd.modifier.name);
STRNCPY(data->socket_identifier, socket.identifier);
data->is_output = is_output;

View File

@ -44,14 +44,14 @@ void SEQ_relations_invalidate_cache_in_range(Scene *scene,
*/
void SEQ_relations_free_all_anim_ibufs(Scene *scene, int timeline_frame);
/**
* A debug and development function which checks whether sequences have unique UUIDs.
* A debug and development function which checks whether sequences have unique UIDs.
* Errors will be reported to the console.
*/
void SEQ_relations_check_uuids_unique_and_report(const Scene *scene);
void SEQ_relations_check_uids_unique_and_report(const Scene *scene);
/**
* Generate new UUID for the given sequence.
* Generate new UID for the given sequence.
*/
void SEQ_relations_session_uuid_generate(Sequence *sequence);
void SEQ_relations_session_uid_generate(Sequence *sequence);
void SEQ_cache_cleanup(Scene *scene);
void SEQ_cache_iterate(

View File

@ -18,7 +18,7 @@
#include "BLI_fileops.h"
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_session_uuid.h"
#include "BLI_session_uid.h"
#include "BLI_string.h"
#ifdef WIN32
@ -67,7 +67,7 @@ struct SeqIndexBuildContext {
Depsgraph *depsgraph;
Scene *scene;
Sequence *seq, *orig_seq;
SessionUUID orig_seq_uuid;
SessionUID orig_seq_uid;
};
int SEQ_rendersize_to_proxysize(int render_size)
@ -477,7 +477,7 @@ bool SEQ_proxy_rebuild_context(Main *bmain,
context->depsgraph = depsgraph;
context->scene = scene;
context->orig_seq = seq;
context->orig_seq_uuid = seq->runtime.session_uuid;
context->orig_seq_uid = seq->runtime.session_uid;
context->seq = nseq;
context->view_id = i; /* only for images */

View File

@ -155,7 +155,7 @@ Sequence *SEQ_sequence_alloc(ListBase *lb, int timeline_frame, int machine, int
SEQ_channels_ensure(&seq->channels);
}
SEQ_relations_session_uuid_generate(seq);
SEQ_relations_session_uid_generate(seq);
return seq;
}
@ -488,7 +488,7 @@ static Sequence *seq_dupli(const Scene *scene_src,
Sequence *seqn = static_cast<Sequence *>(MEM_dupallocN(seq));
if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) {
SEQ_relations_session_uuid_generate(seqn);
SEQ_relations_session_uid_generate(seqn);
}
seq->tmp = seqn;
@ -788,8 +788,8 @@ static bool seq_read_data_cb(Sequence *seq, void *user_data)
BLI_listbase_clear(&seq->anims);
seq->flag &= ~SEQ_FLAG_SKIP_THUMBNAILS;
/* Do as early as possible, so that other parts of reading can rely on valid session UUID. */
SEQ_relations_session_uuid_generate(seq);
/* Do as early as possible, so that other parts of reading can rely on valid session UID. */
SEQ_relations_session_uid_generate(seq);
BLO_read_data_address(reader, &seq->seq1);
BLO_read_data_address(reader, &seq->seq2);

View File

@ -14,7 +14,7 @@
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_math_base.h"
#include "BLI_session_uuid.h"
#include "BLI_session_uid.h"
#include "BKE_main.hh"
#include "BKE_report.h"
@ -408,41 +408,41 @@ void SEQ_relations_sequence_free_anim(Sequence *seq)
BLI_listbase_clear(&seq->anims);
}
void SEQ_relations_session_uuid_generate(Sequence *sequence)
void SEQ_relations_session_uid_generate(Sequence *sequence)
{
sequence->runtime.session_uuid = BLI_session_uuid_generate();
sequence->runtime.session_uid = BLI_session_uid_generate();
}
static bool get_uuids_cb(Sequence *seq, void *user_data)
static bool get_uids_cb(Sequence *seq, void *user_data)
{
GSet *used_uuids = (GSet *)user_data;
const SessionUUID *session_uuid = &seq->runtime.session_uuid;
if (!BLI_session_uuid_is_generated(session_uuid)) {
printf("Sequence %s does not have UUID generated.\n", seq->name);
GSet *used_uids = (GSet *)user_data;
const SessionUID *session_uid = &seq->runtime.session_uid;
if (!BLI_session_uid_is_generated(session_uid)) {
printf("Sequence %s does not have UID generated.\n", seq->name);
return true;
}
if (BLI_gset_lookup(used_uuids, session_uuid) != nullptr) {
printf("Sequence %s has duplicate UUID generated.\n", seq->name);
if (BLI_gset_lookup(used_uids, session_uid) != nullptr) {
printf("Sequence %s has duplicate UID generated.\n", seq->name);
return true;
}
BLI_gset_insert(used_uuids, (void *)session_uuid);
BLI_gset_insert(used_uids, (void *)session_uid);
return true;
}
void SEQ_relations_check_uuids_unique_and_report(const Scene *scene)
void SEQ_relations_check_uids_unique_and_report(const Scene *scene)
{
if (scene->ed == nullptr) {
return;
}
GSet *used_uuids = BLI_gset_new(
BLI_session_uuid_ghash_hash, BLI_session_uuid_ghash_compare, "sequencer used uuids");
GSet *used_uids = BLI_gset_new(
BLI_session_uid_ghash_hash, BLI_session_uid_ghash_compare, "sequencer used uids");
SEQ_for_each_callback(&scene->ed->seqbase, get_uuids_cb, used_uuids);
SEQ_for_each_callback(&scene->ed->seqbase, get_uids_cb, used_uids);
BLI_gset_free(used_uuids, nullptr);
BLI_gset_free(used_uids, nullptr);
}
Sequence *SEQ_find_metastrip_by_sequence(ListBase *seqbase, Sequence *meta, Sequence *seq)

View File

@ -901,33 +901,33 @@ void WM_operator_properties_filesel(wmOperatorType *ot,
short sort);
/**
* Tries to pass \a id to an operator via either a "session_uuid" or a "name" property defined in
* Tries to pass \a id to an operator via either a "session_uid" or a "name" property defined in
* the properties of \a ptr. The former is preferred, since it works properly with linking and
* library overrides (which may both result in multiple IDs with the same name and type).
*
* Also see #WM_operator_properties_id_lookup() and
* #WM_operator_properties_id_lookup_from_name_or_session_uuid()
* #WM_operator_properties_id_lookup_from_name_or_session_uid()
*/
void WM_operator_properties_id_lookup_set_from_id(PointerRNA *ptr, const ID *id);
/**
* Tries to find an ID in \a bmain. There needs to be either a "session_uuid" int or "name" string
* Tries to find an ID in \a bmain. There needs to be either a "session_uid" int or "name" string
* property defined and set. The former has priority. See #WM_operator_properties_id_lookup() for a
* helper to add the properties.
*/
ID *WM_operator_properties_id_lookup_from_name_or_session_uuid(Main *bmain,
PointerRNA *ptr,
enum ID_Type type);
ID *WM_operator_properties_id_lookup_from_name_or_session_uid(Main *bmain,
PointerRNA *ptr,
enum ID_Type type);
/**
* Check if either the "session_uuid" or "name" property is set inside \a ptr. If this is the case
* the ID can be looked up by #WM_operator_properties_id_lookup_from_name_or_session_uuid().
* Check if either the "session_uid" or "name" property is set inside \a ptr. If this is the case
* the ID can be looked up by #WM_operator_properties_id_lookup_from_name_or_session_uid().
*/
bool WM_operator_properties_id_lookup_is_set(PointerRNA *ptr);
/**
* Adds "name" and "session_uuid" properties so the caller can tell the operator which ID to act
* on. See #WM_operator_properties_id_lookup_from_name_or_session_uuid(). Both properties will be
* Adds "name" and "session_uid" properties so the caller can tell the operator which ID to act
* on. See #WM_operator_properties_id_lookup_from_name_or_session_uid(). Both properties will be
* hidden in the UI and not be saved over consecutive operator calls.
*
* \note New operators should probably use "session_uuid" only (set \a add_name_prop to #false),
* \note New operators should probably use "session_uid" only (set \a add_name_prop to #false),
* since this works properly with linked data and/or library overrides (in both cases, multiple IDs
* with the same name and type may be present). The "name" property is only kept to not break
* compatibility with old scripts using some previously existing operators.

View File

@ -782,9 +782,9 @@ void WM_drag_free_imported_drag_ID(Main *bmain, wmDrag *drag, wmDropBox *drop)
}
ID_Type asset_id_type = asset_drag->asset->get_id_type();
/* Try to find the imported ID. For this to work either a "session_uuid" or "name" property must
/* Try to find the imported ID. For this to work either a "session_uid" or "name" property must
* have been defined (see #WM_operator_properties_id_lookup()). */
ID *id = WM_operator_properties_id_lookup_from_name_or_session_uuid(
ID *id = WM_operator_properties_id_lookup_from_name_or_session_uid(
bmain, drop->ptr, asset_id_type);
if (id != nullptr) {
/* Do not delete the dragged ID if it has any user, otherwise if it is a 're-used' ID it will

View File

@ -228,11 +228,11 @@ void WM_operator_properties_filesel(wmOperatorType *ot,
void WM_operator_properties_id_lookup_set_from_id(PointerRNA *ptr, const ID *id)
{
PropertyRNA *prop_session_uuid = RNA_struct_find_property(ptr, "session_uuid");
PropertyRNA *prop_session_uid = RNA_struct_find_property(ptr, "session_uid");
PropertyRNA *prop_name = RNA_struct_find_property(ptr, "name");
if (prop_session_uuid) {
RNA_int_set(ptr, "session_uuid", int(id->session_uuid));
if (prop_session_uid) {
RNA_int_set(ptr, "session_uid", int(id->session_uid));
}
else if (prop_name) {
RNA_string_set(ptr, "name", id->name + 2);
@ -242,14 +242,14 @@ void WM_operator_properties_id_lookup_set_from_id(PointerRNA *ptr, const ID *id)
}
}
ID *WM_operator_properties_id_lookup_from_name_or_session_uuid(Main *bmain,
PointerRNA *ptr,
const ID_Type type)
ID *WM_operator_properties_id_lookup_from_name_or_session_uid(Main *bmain,
PointerRNA *ptr,
const ID_Type type)
{
PropertyRNA *prop_session_uuid = RNA_struct_find_property(ptr, "session_uuid");
if (prop_session_uuid && RNA_property_is_set(ptr, prop_session_uuid)) {
const uint32_t session_uuid = uint32_t(RNA_property_int_get(ptr, prop_session_uuid));
return BKE_libblock_find_session_uuid(bmain, type, session_uuid);
PropertyRNA *prop_session_uid = RNA_struct_find_property(ptr, "session_uid");
if (prop_session_uid && RNA_property_is_set(ptr, prop_session_uid)) {
const uint32_t session_uid = uint32_t(RNA_property_int_get(ptr, prop_session_uid));
return BKE_libblock_find_session_uid(bmain, type, session_uid);
}
PropertyRNA *prop_name = RNA_struct_find_property(ptr, "name");
@ -264,8 +264,7 @@ ID *WM_operator_properties_id_lookup_from_name_or_session_uuid(Main *bmain,
bool WM_operator_properties_id_lookup_is_set(PointerRNA *ptr)
{
return RNA_struct_property_is_set(ptr, "session_uuid") ||
RNA_struct_property_is_set(ptr, "name");
return RNA_struct_property_is_set(ptr, "session_uid") || RNA_struct_property_is_set(ptr, "name");
}
void WM_operator_properties_id_lookup(wmOperatorType *ot, const bool add_name_prop)
@ -283,12 +282,12 @@ void WM_operator_properties_id_lookup(wmOperatorType *ot, const bool add_name_pr
}
prop = RNA_def_int(ot->srna,
"session_uuid",
"session_uid",
0,
INT32_MIN,
INT32_MAX,
"Session UUID",
"Session UUID of the data-block to use by the operator",
"Session UID",
"Session UID of the data-block to use by the operator",
INT32_MIN,
INT32_MAX);
RNA_def_property_flag(prop, (PropertyFlag)(PROP_SKIP_SAVE | PROP_HIDDEN));

View File

@ -1564,7 +1564,7 @@ ID *WM_operator_drop_load_path(bContext *C, wmOperator *op, const short idcode)
}
/* Lookup an already existing ID. */
id = WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, ID_Type(idcode));
id = WM_operator_properties_id_lookup_from_name_or_session_uid(bmain, op->ptr, ID_Type(idcode));
if (!id) {
/* Print error with the name if the name is available. */

View File

@ -659,7 +659,7 @@ static void print_help(bArgs *ba, bool all)
BLI_args_print_arg_doc(ba, "--debug-depsgraph-no-threads");
BLI_args_print_arg_doc(ba, "--debug-depsgraph-time");
BLI_args_print_arg_doc(ba, "--debug-depsgraph-pretty");
BLI_args_print_arg_doc(ba, "--debug-depsgraph-uuid");
BLI_args_print_arg_doc(ba, "--debug-depsgraph-uid");
BLI_args_print_arg_doc(ba, "--debug-ghost");
BLI_args_print_arg_doc(ba, "--debug-wintab");
BLI_args_print_arg_doc(ba, "--debug-gpu");
@ -1107,7 +1107,7 @@ static const char arg_handle_debug_mode_generic_set_doc_depsgraph_no_threads[] =
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_pretty[] =
"\n\t"
"Enable colors for dependency graph debug messages.";
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_uuid[] =
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_uid[] =
"\n\t"
"Verify validness of session-wide identifiers assigned to ID datablocks.";
static const char arg_handle_debug_mode_generic_set_doc_gpu_force_workarounds[] =
@ -2461,9 +2461,9 @@ void main_args_setup(bContext *C, bArgs *ba, bool all)
(void *)G_DEBUG_DEPSGRAPH_PRETTY);
BLI_args_add(ba,
nullptr,
"--debug-depsgraph-uuid",
CB_EX(arg_handle_debug_mode_generic_set, depsgraph_uuid),
(void *)G_DEBUG_DEPSGRAPH_UUID);
"--debug-depsgraph-uid",
CB_EX(arg_handle_debug_mode_generic_set, depsgraph_uid),
(void *)G_DEBUG_DEPSGRAPH_UID);
BLI_args_add(ba,
nullptr,
"--debug-gpu-force-workarounds",