Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2021-02-25 12:17:31 +0300
committerBastien Montagne <bastien@blender.org>2021-02-25 13:39:10 +0300
commitde25b79ff5c4da7d2d604eaa33b8c520c246679b (patch)
treecf5f47ff016802ca3c90171d290ad0a2edb9a361 /source/blender/makesrna/intern/rna_access.c
parentb5d39f9b469e6a1688bb4498f6635bd5e23a35ef (diff)
Refactor: IDTypeInfo: Add `owner_get` to get owner of embedded IDs.
This concerns currently only collections (`master_collection` of scenes) and root node trees. It removes the matching type-specific helpers (`BKE_collection_master_scene_search` and `BKE_node_tree_find_owner_ID`). No functional change expected here. NOTE: Current implementation of `owner_get` is far from optimal, we could probably do it better, see {T69169}. NOTE: While it could also have it, shapekeys IDTypeInfo was left out of this change for now. Mainly because it sould not be used currently, and we ultimately want to demote shape keys from ID status anyway.
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r--source/blender/makesrna/intern/rna_access.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index d8c91cb2923..c5dd516d16e 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -5826,26 +5826,29 @@ ID *RNA_find_real_ID_and_path(Main *bmain, ID *id, const char **r_path)
*r_path = "";
}
- if ((id != NULL) && (id->flag & LIB_EMBEDDED_DATA)) {
+ if ((id == NULL) || (id->flag & LIB_EMBEDDED_DATA) == 0) {
+ return id;
+ }
+
+ const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
+ if (r_path) {
switch (GS(id->name)) {
case ID_NT:
- if (r_path) {
- *r_path = "node_tree";
- }
- return BKE_node_tree_find_owner_ID(bmain, (bNodeTree *)id);
+ *r_path = "node_tree";
+ break;
case ID_GR:
- if (r_path) {
- *r_path = "collection";
- }
- return (ID *)BKE_collection_master_scene_search(bmain, (struct Collection *)id);
-
+ *r_path = "collection";
+ break;
default:
- return NULL;
+ BLI_assert(!"Missing handling of embedded id type.");
}
}
- else {
+
+ if (id_type->owner_get == NULL) {
+ BLI_assert(!"Missing handling of embedded id type.");
return id;
}
+ return id_type->owner_get(bmain, id);
}
static char *rna_prepend_real_ID_path(Main *bmain, ID *id, char *path, ID **r_real_id)