Cleanup: rename 'private' to 'embedded' for sub-data IDs.
'Private' can be a rather confusing term, especially when considering its meaning in programming languages. So now root node trees and master collections are 'embedded' IDs instead.
This commit is contained in:
parent
8820ab41bd
commit
68c0d77b0c
|
@ -55,14 +55,14 @@ enum {
|
|||
IDWALK_CB_INDIRECT_USAGE = (1 << 2),
|
||||
|
||||
/**
|
||||
* That ID is used as mere sub-data by its owner
|
||||
* (only case currently: those f***ing nodetrees in materials etc.).
|
||||
* This means callback shall not *do* anything,
|
||||
* only use this as informative data if it needs it.
|
||||
* That ID is used as mere sub-data by its owner (only case currently: those root nodetrees in
|
||||
* materials etc., and the Scene's master collections).
|
||||
* This means callback shall not *do* anything, only use this as informative data if it needs it.
|
||||
*/
|
||||
IDWALK_CB_PRIVATE = (1 << 3),
|
||||
IDWALK_CB_EMBEDDED = (1 << 3),
|
||||
|
||||
/** That ID is not really used by its owner, it's just an internal hint/helper.
|
||||
/**
|
||||
* That ID is not really used by its owner, it's just an internal hint/helper.
|
||||
* This addresses Their Highest Ugliness the 'from' pointers: Object->from_proxy and Key->from.
|
||||
* How to handle that kind of cases totally depends on what caller code is doing... */
|
||||
IDWALK_CB_LOOPBACK = (1 << 4),
|
||||
|
|
|
@ -89,7 +89,7 @@ static void collection_copy_data(Main *bmain, ID *id_dst, const ID *id_src, cons
|
|||
const Collection *collection_src = (const Collection *)id_src;
|
||||
|
||||
BLI_assert(((collection_src->flag & COLLECTION_IS_MASTER) != 0) ==
|
||||
((collection_src->id.flag & LIB_PRIVATE_DATA) != 0));
|
||||
((collection_src->id.flag & LIB_EMBEDDED_DATA) != 0));
|
||||
|
||||
/* Do not copy collection's preview (same behavior as for objects). */
|
||||
if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0 && false) { /* XXX TODO temp hack */
|
||||
|
@ -366,7 +366,7 @@ Collection *BKE_collection_duplicate(Main *bmain,
|
|||
const bool do_obdata)
|
||||
{
|
||||
/* It's not allowed to copy the master collection. */
|
||||
BLI_assert((collection->id.flag & LIB_PRIVATE_DATA) == 0);
|
||||
BLI_assert((collection->id.flag & LIB_EMBEDDED_DATA) == 0);
|
||||
BLI_assert((collection->flag & COLLECTION_IS_MASTER) == 0);
|
||||
if (collection->flag & COLLECTION_IS_MASTER) {
|
||||
return NULL;
|
||||
|
@ -514,7 +514,7 @@ Collection *BKE_collection_master_add()
|
|||
/* Not an actual datablock, but owned by scene. */
|
||||
Collection *master_collection = MEM_callocN(sizeof(Collection), "Master Collection");
|
||||
STRNCPY(master_collection->id.name, "GRMaster Collection");
|
||||
master_collection->id.flag |= LIB_PRIVATE_DATA;
|
||||
master_collection->id.flag |= LIB_EMBEDDED_DATA;
|
||||
master_collection->flag |= COLLECTION_IS_MASTER;
|
||||
return master_collection;
|
||||
}
|
||||
|
|
|
@ -340,7 +340,7 @@ static int lib_id_expand_local_cb(LibraryIDLinkCallbackData *cb_data)
|
|||
ID *id_self = cb_data->id_self;
|
||||
ID **id_pointer = cb_data->id_pointer;
|
||||
int const cb_flag = cb_data->cb_flag;
|
||||
if (cb_flag & IDWALK_CB_PRIVATE) {
|
||||
if (cb_flag & IDWALK_CB_EMBEDDED) {
|
||||
return IDWALK_RET_NOP;
|
||||
}
|
||||
|
||||
|
@ -1148,7 +1148,7 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int ori
|
|||
ID *new_id = *r_newid;
|
||||
int flag = orig_flag;
|
||||
|
||||
const bool is_private_id_data = (id->flag & LIB_PRIVATE_DATA) != 0;
|
||||
const bool is_private_id_data = (id->flag & LIB_EMBEDDED_DATA) != 0;
|
||||
|
||||
BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) != 0 || bmain != NULL);
|
||||
BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) != 0 || (flag & LIB_ID_CREATE_NO_ALLOCATE) == 0);
|
||||
|
@ -1167,7 +1167,7 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int ori
|
|||
}
|
||||
|
||||
/* The id->flag bits to copy over. */
|
||||
const int copy_idflag_mask = LIB_PRIVATE_DATA;
|
||||
const int copy_idflag_mask = LIB_EMBEDDED_DATA;
|
||||
|
||||
if ((flag & LIB_ID_CREATE_NO_ALLOCATE) != 0) {
|
||||
/* r_newid already contains pointer to allocated memory. */
|
||||
|
@ -1744,7 +1744,7 @@ static void library_make_local_copying_check(ID *id,
|
|||
}
|
||||
|
||||
/* Shapekeys are considered 'private' to their owner ID here, and never tagged
|
||||
* (since they cannot be linked), * so we have to switch effective parent to their owner.
|
||||
* (since they cannot be linked), so we have to switch effective parent to their owner.
|
||||
*/
|
||||
if (GS(par_id->name) == ID_KE) {
|
||||
par_id = ((Key *)par_id)->from;
|
||||
|
|
|
@ -137,11 +137,15 @@ enum {
|
|||
|
||||
typedef struct LibraryForeachIDData {
|
||||
Main *bmain;
|
||||
/* 'Real' ID, the one that might be in bmain, only differs from self_id when the later is a
|
||||
* private one. */
|
||||
/**
|
||||
* 'Real' ID, the one that might be in bmain, only differs from self_id when the later is a
|
||||
* private one.
|
||||
*/
|
||||
ID *owner_id;
|
||||
/* ID from which the current ID pointer is being processed. It may be a 'private' ID like master
|
||||
* collection or root node tree. */
|
||||
/**
|
||||
* ID from which the current ID pointer is being processed. It may be an embedded ID like master
|
||||
* collection or root node tree.
|
||||
*/
|
||||
ID *self_id;
|
||||
|
||||
int flag;
|
||||
|
@ -343,8 +347,8 @@ static void library_foreach_layer_collection(LibraryForeachIDData *data, ListBas
|
|||
/* XXX This is very weak. The whole idea of keeping pointers to private IDs is very bad
|
||||
* anyway... */
|
||||
const int cb_flag = (lc->collection != NULL &&
|
||||
(lc->collection->id.flag & LIB_PRIVATE_DATA) != 0) ?
|
||||
IDWALK_CB_PRIVATE :
|
||||
(lc->collection->id.flag & LIB_EMBEDDED_DATA) != 0) ?
|
||||
IDWALK_CB_EMBEDDED :
|
||||
IDWALK_CB_NOP;
|
||||
FOREACH_CALLBACK_INVOKE(data, lc->collection, cb_flag);
|
||||
library_foreach_layer_collection(data, &lc->layer_collections);
|
||||
|
@ -367,8 +371,8 @@ static void library_foreach_collection(LibraryForeachIDData *data, Collection *c
|
|||
/* XXX This is very weak. The whole idea of keeping pointers to private IDs is very bad
|
||||
* anyway... */
|
||||
const int cb_flag = ((parent->collection != NULL &&
|
||||
(parent->collection->id.flag & LIB_PRIVATE_DATA) != 0) ?
|
||||
IDWALK_CB_PRIVATE :
|
||||
(parent->collection->id.flag & LIB_EMBEDDED_DATA) != 0) ?
|
||||
IDWALK_CB_EMBEDDED :
|
||||
IDWALK_CB_NOP);
|
||||
FOREACH_CALLBACK_INVOKE(
|
||||
data, parent->collection, IDWALK_CB_NEVER_SELF | IDWALK_CB_LOOPBACK | cb_flag);
|
||||
|
@ -484,13 +488,13 @@ static void library_foreach_screen_area(LibraryForeachIDData *data, ScrArea *are
|
|||
FOREACH_CALLBACK_INVOKE_ID(data, snode->from, IDWALK_CB_NOP);
|
||||
|
||||
FOREACH_CALLBACK_INVOKE(
|
||||
data, snode->nodetree, is_private_nodetree ? IDWALK_CB_PRIVATE : IDWALK_CB_USER);
|
||||
data, snode->nodetree, is_private_nodetree ? IDWALK_CB_EMBEDDED : IDWALK_CB_USER);
|
||||
|
||||
for (path = snode->treepath.first; path; path = path->next) {
|
||||
if (path == snode->treepath.first) {
|
||||
/* first nodetree in path is same as snode->nodetree */
|
||||
FOREACH_CALLBACK_INVOKE(
|
||||
data, path->nodetree, is_private_nodetree ? IDWALK_CB_PRIVATE : IDWALK_CB_NOP);
|
||||
data, path->nodetree, is_private_nodetree ? IDWALK_CB_EMBEDDED : IDWALK_CB_NOP);
|
||||
}
|
||||
else {
|
||||
FOREACH_CALLBACK_INVOKE(data, path->nodetree, IDWALK_CB_USER);
|
||||
|
@ -527,7 +531,7 @@ static void library_foreach_ID_as_subdata_link(ID **id_pp,
|
|||
{
|
||||
/* Needed e.g. for callbacks handling relationships... This call shall be absolutely readonly. */
|
||||
ID *id = *id_pp;
|
||||
FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pp, IDWALK_CB_PRIVATE);
|
||||
FOREACH_CALLBACK_INVOKE_ID_PP(data, id_pp, IDWALK_CB_EMBEDDED);
|
||||
BLI_assert(id == *id_pp);
|
||||
|
||||
if (flag & IDWALK_RECURSE) {
|
||||
|
@ -583,7 +587,7 @@ static void library_foreach_ID_link(Main *bmain,
|
|||
|
||||
for (; id != NULL; id = (flag & IDWALK_RECURSE) ? BLI_LINKSTACK_POP(data.ids_todo) : NULL) {
|
||||
data.self_id = id;
|
||||
data.owner_id = (id->flag & LIB_PRIVATE_DATA) ? id_owner : data.self_id;
|
||||
data.owner_id = (id->flag & LIB_EMBEDDED_DATA) ? id_owner : data.self_id;
|
||||
|
||||
/* inherit_data is non-NULL when this function is called for some sub-data ID
|
||||
* (like root nodetree of a material).
|
||||
|
|
|
@ -94,7 +94,7 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data)
|
|||
{
|
||||
const int cb_flag = cb_data->cb_flag;
|
||||
|
||||
if (cb_flag & IDWALK_CB_PRIVATE) {
|
||||
if (cb_flag & IDWALK_CB_EMBEDDED) {
|
||||
return IDWALK_RET_NOP;
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data)
|
|||
/* Those asserts ensure the general sanity of ID tags regarding 'embeded' ID data (root nodetrees
|
||||
* and co). */
|
||||
BLI_assert(id_owner == id_remap_data->id_owner);
|
||||
BLI_assert(id_self == id_owner || (id_self->flag & LIB_PRIVATE_DATA) != 0);
|
||||
BLI_assert(id_self == id_owner || (id_self->flag & LIB_EMBEDDED_DATA) != 0);
|
||||
|
||||
if (!old_id) { /* Used to cleanup all IDs used by a specific one. */
|
||||
BLI_assert(!new_id);
|
||||
|
@ -653,7 +653,7 @@ void BKE_libblock_relink_ex(
|
|||
static int id_relink_to_newid_looper(LibraryIDLinkCallbackData *cb_data)
|
||||
{
|
||||
const int cb_flag = cb_data->cb_flag;
|
||||
if (cb_flag & IDWALK_CB_PRIVATE) {
|
||||
if (cb_flag & IDWALK_CB_EMBEDDED) {
|
||||
return IDWALK_RET_NOP;
|
||||
}
|
||||
|
||||
|
|
|
@ -1654,7 +1654,7 @@ bNodeTree *ntreeAddTree(Main *bmain, const char *name, const char *idname)
|
|||
}
|
||||
else {
|
||||
ntree = MEM_callocN(sizeof(bNodeTree), "new node tree");
|
||||
ntree->id.flag |= LIB_PRIVATE_DATA;
|
||||
ntree->id.flag |= LIB_EMBEDDED_DATA;
|
||||
*((short *)ntree->id.name) = ID_NT;
|
||||
BLI_strncpy(ntree->id.name + 2, name, sizeof(ntree->id.name));
|
||||
}
|
||||
|
|
|
@ -7790,7 +7790,7 @@ static int lib_link_main_data_restore_cb(LibraryIDLinkCallbackData *cb_data)
|
|||
{
|
||||
const int cb_flag = cb_data->cb_flag;
|
||||
ID **id_pointer = cb_data->id_pointer;
|
||||
if (cb_flag & IDWALK_CB_PRIVATE || *id_pointer == NULL) {
|
||||
if (cb_flag & IDWALK_CB_EMBEDDED || *id_pointer == NULL) {
|
||||
return IDWALK_RET_NOP;
|
||||
}
|
||||
|
||||
|
@ -7801,7 +7801,7 @@ static int lib_link_main_data_restore_cb(LibraryIDLinkCallbackData *cb_data)
|
|||
Collection *collection = (Collection *)*id_pointer;
|
||||
if (collection->flag & COLLECTION_IS_MASTER) {
|
||||
/* We should never reach that point anymore, since master collection private ID should be
|
||||
* properly tagged with IDWALK_CB_PRIVATE. */
|
||||
* properly tagged with IDWALK_CB_EMBEDDED. */
|
||||
BLI_assert(0);
|
||||
return IDWALK_RET_NOP;
|
||||
}
|
||||
|
|
|
@ -4089,7 +4089,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
FOREACH_MAIN_ID_BEGIN (bmain, id) {
|
||||
bNodeTree *ntree = ntreeFromID(id);
|
||||
if (ntree) {
|
||||
ntree->id.flag |= LIB_PRIVATE_DATA;
|
||||
ntree->id.flag |= LIB_EMBEDDED_DATA;
|
||||
}
|
||||
}
|
||||
FOREACH_MAIN_ID_END;
|
||||
|
@ -4106,7 +4106,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
/* Older files do not have a master collection, which is then added through
|
||||
* `BKE_collection_master_add()`, so everything is fine. */
|
||||
if (scene->master_collection != NULL) {
|
||||
scene->master_collection->id.flag |= LIB_PRIVATE_DATA;
|
||||
scene->master_collection->id.flag |= LIB_EMBEDDED_DATA;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -465,16 +465,20 @@ typedef enum ID_Type {
|
|||
if ((a) && (a)->id.newid) \
|
||||
(a) = (void *)(a)->id.newid
|
||||
|
||||
/* id->flag (persitent). */
|
||||
/** id->flag (persitent). */
|
||||
enum {
|
||||
/* Don't delete the datablock even if unused. */
|
||||
/** Don't delete the datablock even if unused. */
|
||||
LIB_FAKEUSER = 1 << 9,
|
||||
/* The datablock structure is a sub-object of a different one.
|
||||
* Direct persistent references are not allowed. */
|
||||
LIB_PRIVATE_DATA = 1 << 10,
|
||||
/* Datablock is from a library and linked indirectly, with LIB_TAG_INDIRECT
|
||||
/**
|
||||
* The data-block is a sub-data of another one.
|
||||
* Direct persistent references are not allowed.
|
||||
*/
|
||||
LIB_EMBEDDED_DATA = 1 << 10,
|
||||
/**
|
||||
* Datablock is from a library and linked indirectly, with LIB_TAG_INDIRECT
|
||||
* tag set. But the current .blend file also has a weak pointer to it that
|
||||
* we want to restore if possible, and silently drop if it's missing. */
|
||||
* we want to restore if possible, and silently drop if it's missing.
|
||||
*/
|
||||
LIB_INDIRECT_WEAK_LINK = 1 << 11,
|
||||
};
|
||||
|
||||
|
|
|
@ -5832,7 +5832,7 @@ ID *RNA_find_real_ID_and_path(Main *bmain, ID *id, const char **r_path)
|
|||
*r_path = "";
|
||||
}
|
||||
|
||||
if ((id != NULL) && (id->flag & LIB_PRIVATE_DATA)) {
|
||||
if ((id != NULL) && (id->flag & LIB_EMBEDDED_DATA)) {
|
||||
switch (GS(id->name)) {
|
||||
case ID_NT:
|
||||
if (r_path) {
|
||||
|
|
|
@ -923,7 +923,7 @@ static PyObject *pyrna_struct_repr(BPy_StructRNA *self)
|
|||
if (DEG_get_original_id(id) != id) {
|
||||
ret = PyUnicode_FromFormat("Evaluated %s %R", BKE_idcode_to_name(GS(id->name)), tmp_str);
|
||||
}
|
||||
else if (RNA_struct_is_ID(self->ptr.type) && (id->flag & LIB_PRIVATE_DATA) == 0) {
|
||||
else if (RNA_struct_is_ID(self->ptr.type) && (id->flag & LIB_EMBEDDED_DATA) == 0) {
|
||||
ret = PyUnicode_FromFormat(
|
||||
"bpy.data.%s[%R]", BKE_idcode_to_name_plural(GS(id->name)), tmp_str);
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ static int foreach_libblock_id_user_map_callback(LibraryIDLinkCallbackData *cb_d
|
|||
return IDWALK_RET_NOP;
|
||||
}
|
||||
|
||||
if (cb_flag & IDWALK_CB_PRIVATE) {
|
||||
if (cb_flag & IDWALK_CB_EMBEDDED) {
|
||||
/* We skip private pointers themselves, like root node trees, we'll 'link' their own ID
|
||||
* pointers to their 'ID owner' instead. */
|
||||
return IDWALK_RET_NOP;
|
||||
|
|
|
@ -3340,7 +3340,7 @@ static int previews_id_ensure_callback(LibraryIDLinkCallbackData *cb_data)
|
|||
{
|
||||
const int cb_flag = cb_data->cb_flag;
|
||||
|
||||
if (cb_flag & IDWALK_CB_PRIVATE) {
|
||||
if (cb_flag & IDWALK_CB_EMBEDDED) {
|
||||
return IDWALK_RET_NOP;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue