Cleanup: IDManagement: Simplify owner_get calllback of IDTypeInfo.

Now that all embedded IDs have a loopback pointer to their owner, we do
need anymore extra parameters for this accessor.
This commit is contained in:
2022-09-06 18:21:16 +02:00
parent e46687c3aa
commit 0c242ff72b
9 changed files with 11 additions and 16 deletions

View File

@@ -85,11 +85,7 @@ typedef void (*IDTypeForeachCacheFunction)(struct ID *id,
typedef void (*IDTypeForeachPathFunction)(struct ID *id, struct BPathForeachPathData *bpath_data);
/** \param owner_id_hint: If non-NULL, a potential owner of the given embedded ID. Can speed up
* look-up of the owner ID in some cases. */
typedef struct ID *(*IDTypeEmbeddedOwnerGetFunction)(struct Main *bmain,
struct ID *id,
struct ID *owner_id_hint);
typedef struct ID *(*IDTypeEmbeddedOwnerGetFunction)(struct ID *id);
typedef void (*IDTypeBlendWriteFunction)(struct BlendWriter *writer,
struct ID *id,

View File

@@ -169,7 +169,7 @@ static void collection_foreach_id(ID *id, LibraryForeachIDData *data)
}
}
static ID *collection_owner_get(Main *bmain, ID *id, ID *UNUSED(owner_id_hint))
static ID *collection_owner_get(ID *id)
{
if ((id->flag & LIB_EMBEDDED_DATA) == 0) {
return id;

View File

@@ -91,7 +91,7 @@ static void shapekey_foreach_id(ID *id, LibraryForeachIDData *data)
BKE_LIB_FOREACHID_PROCESS_ID(data, key->from, IDWALK_CB_LOOPBACK);
}
static ID *shapekey_owner_get(Main *UNUSED(bmain), ID *id, ID *UNUSED(owner_id_hint))
static ID *shapekey_owner_get(ID *id)
{
Key *key = (Key *)id;

View File

@@ -105,8 +105,7 @@ BLI_INLINE const IDOverrideLibrary *BKE_lib_override_library_get(const Main *bma
if (id_type->owner_get != nullptr) {
/* The #IDTypeInfo::owner_get callback should not modify the arguments, so casting away const
* is okay. */
const ID *owner_id = id_type->owner_get(
const_cast<Main *>(bmain), const_cast<ID *>(id), const_cast<ID *>(owner_id_hint));
const ID *owner_id = id_type->owner_get(const_cast<ID *>(id));
if (r_owner_id != nullptr) {
*r_owner_id = owner_id;
}
@@ -2214,7 +2213,7 @@ static ID *lib_override_library_main_resync_root_get(Main *bmain, ID *id)
if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) {
const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
if (id_type->owner_get != nullptr) {
id = id_type->owner_get(bmain, id, nullptr);
id = id_type->owner_get(id);
}
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id));
}

View File

@@ -713,7 +713,7 @@ static void lib_query_unused_ids_tag_recurse(Main *bmain,
/* Directly 'by-pass' to actual real ID owner. */
const IDTypeInfo *type_info_from = BKE_idtype_get_info_from_id(id_from);
BLI_assert(type_info_from->owner_get != NULL);
id_from = type_info_from->owner_get(bmain, id_from, NULL);
id_from = type_info_from->owner_get(id_from);
}
lib_query_unused_ids_tag_recurse(

View File

@@ -401,7 +401,7 @@ static void node_foreach_path(ID *id, BPathForeachPathData *bpath_data)
}
}
static ID *node_owner_get(Main *UNUSED(bmain), ID *id, ID *UNUSED(owner_id_hint))
static ID *node_owner_get(ID *id)
{
if ((id->flag & LIB_EMBEDDED_DATA) == 0) {
return id;

View File

@@ -380,7 +380,7 @@ void outliner_collection_delete(
const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(&parent->id);
BLI_assert(id_type->owner_get != nullptr);
ID *scene_owner = id_type->owner_get(bmain, &parent->id, nullptr);
ID *scene_owner = id_type->owner_get(&parent->id);
BLI_assert(GS(scene_owner->name) == ID_SCE);
if (ID_IS_LINKED(scene_owner) || ID_IS_OVERRIDE_LIBRARY(scene_owner)) {
skip = true;
@@ -613,7 +613,7 @@ static int collection_duplicate_exec(bContext *C, wmOperator *op)
const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(&parent->id);
BLI_assert(id_type->owner_get != nullptr);
Scene *scene_owner = (Scene *)id_type->owner_get(bmain, &parent->id, nullptr);
Scene *scene_owner = (Scene *)id_type->owner_get(&parent->id);
BLI_assert(scene_owner != nullptr);
BLI_assert(GS(scene_owner->id.name) == ID_SCE);

View File

@@ -944,7 +944,7 @@ ID *RNA_find_real_ID_and_path(Main *bmain, ID *id, const char **r_path)
BLI_assert_msg(0, "Missing handling of embedded id type.");
return id;
}
return id_type->owner_get(bmain, id, nullptr);
return id_type->owner_get(id);
}
static char *rna_prepend_real_ID_path(Main *bmain, ID *id, char *path, ID **r_real_id)

View File

@@ -1483,7 +1483,7 @@ static void rna_ImageFormatSettings_color_management_set(PointerRNA *ptr, int va
if (owner_id && GS(owner_id->name) == ID_NT) {
/* For compositing nodes, find the corresponding scene. */
const IDTypeInfo *type_info = BKE_idtype_get_info_from_id(owner_id);
owner_id = type_info->owner_get(G_MAIN, owner_id, NULL);
owner_id = type_info->owner_get(owner_id);
}
if (owner_id && GS(owner_id->name) == ID_SCE) {
BKE_image_format_color_management_copy_from_scene(imf, (Scene *)owner_id);