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:
-rw-r--r--source/blender/blenkernel/BKE_lib_id.h7
-rw-r--r--source/blender/blenkernel/intern/lib_id.c9
-rw-r--r--source/blender/blenkernel/intern/lib_override.cc28
-rw-r--r--source/blender/blenkernel/intern/lib_query.c5
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.cc11
-rw-r--r--source/blender/makesrna/intern/rna_path.cc9
-rw-r--r--source/blender/makesrna/intern/rna_scene.c3
7 files changed, 38 insertions, 34 deletions
diff --git a/source/blender/blenkernel/BKE_lib_id.h b/source/blender/blenkernel/BKE_lib_id.h
index febdad2ca0d..4e4b393fcd6 100644
--- a/source/blender/blenkernel/BKE_lib_id.h
+++ b/source/blender/blenkernel/BKE_lib_id.h
@@ -620,6 +620,13 @@ bool BKE_id_is_in_global_main(struct ID *id);
bool BKE_id_can_be_asset(const struct ID *id);
+/**
+ * Return the owner ID of the given `id`, if any.
+ *
+ * \note: This will only return non-NULL for embedded IDs (master collections etc.), and shapekeys.
+ */
+struct ID *BKE_id_owner_get(struct ID *id);
+
/** Check if that ID can be considered as editable from a high-level (editor) perspective.
*
* NOTE: This used to be done with a check on whether ID was linked or not, but now with system
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index 5a394a05d86..cead6702080 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -1965,6 +1965,15 @@ bool BKE_id_can_be_asset(const ID *id)
BKE_idtype_idcode_is_linkable(GS(id->name));
}
+ID *BKE_id_owner_get(ID *id)
+{
+ const IDTypeInfo *idtype = BKE_idtype_get_info_from_id(id);
+ if (idtype->owner_get != NULL) {
+ return idtype->owner_get(id);
+ }
+ return NULL;
+}
+
bool BKE_id_is_editable(const Main *bmain, const ID *id)
{
return !(ID_IS_LINKED(id) || BKE_lib_override_library_is_system_defined(bmain, id));
diff --git a/source/blender/blenkernel/intern/lib_override.cc b/source/blender/blenkernel/intern/lib_override.cc
index a85a6c5730f..0200b534ace 100644
--- a/source/blender/blenkernel/intern/lib_override.cc
+++ b/source/blender/blenkernel/intern/lib_override.cc
@@ -97,21 +97,17 @@ BLI_INLINE const IDOverrideLibrary *BKE_lib_override_library_get(const Main * /*
const ID * /*owner_id_hint*/,
const ID **r_owner_id)
{
- if (r_owner_id != nullptr) {
- *r_owner_id = id;
- }
if (id->flag & LIB_EMBEDDED_DATA_LIB_OVERRIDE) {
- const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
- 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<ID *>(id));
- if (r_owner_id != nullptr) {
- *r_owner_id = owner_id;
- }
- return owner_id->override_library;
+ const ID *owner_id = BKE_id_owner_get(const_cast<ID *>(id));
+ BLI_assert_msg(owner_id != nullptr, "Liboverride-embedded ID with no owner");
+ if (r_owner_id != nullptr) {
+ *r_owner_id = owner_id;
}
- BLI_assert_msg(0, "IDTypeInfo of liboverride-embedded ID with no owner getter");
+ return owner_id->override_library;
+ }
+
+ if (r_owner_id != nullptr) {
+ *r_owner_id = id;
}
return id->override_library;
}
@@ -2211,9 +2207,9 @@ static bool lib_override_resync_id_lib_level_is_valid(ID *id,
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(id);
+ ID *id_owner = BKE_id_owner_get(id);
+ if (id_owner != nullptr) {
+ id = id_owner;
}
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id));
}
diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c
index e51f3c524fa..50843b18d18 100644
--- a/source/blender/blenkernel/intern/lib_query.c
+++ b/source/blender/blenkernel/intern/lib_query.c
@@ -711,9 +711,8 @@ static void lib_query_unused_ids_tag_recurse(Main *bmain,
ID *id_from = id_from_item->id_pointer.from;
if ((id_from->flag & LIB_EMBEDDED_DATA) != 0) {
/* 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(id_from);
+ id_from = BKE_id_owner_get(id_from);
+ BLI_assert(id_from != NULL);
}
lib_query_unused_ids_tag_recurse(
diff --git a/source/blender/editors/space_outliner/outliner_collections.cc b/source/blender/editors/space_outliner/outliner_collections.cc
index 0ded4654c80..6b1ca5a53f8 100644
--- a/source/blender/editors/space_outliner/outliner_collections.cc
+++ b/source/blender/editors/space_outliner/outliner_collections.cc
@@ -377,10 +377,8 @@ void outliner_collection_delete(
if (parent->flag & COLLECTION_IS_MASTER) {
BLI_assert(parent->id.flag & LIB_EMBEDDED_DATA);
- 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(&parent->id);
+ ID *scene_owner = BKE_id_owner_get(&parent->id);
+ BLI_assert(scene_owner != nullptr);
BLI_assert(GS(scene_owner->name) == ID_SCE);
if (ID_IS_LINKED(scene_owner) || ID_IS_OVERRIDE_LIBRARY(scene_owner)) {
skip = true;
@@ -610,10 +608,7 @@ static int collection_duplicate_exec(bContext *C, wmOperator *op)
else if (parent != nullptr && (parent->flag & COLLECTION_IS_MASTER) != 0) {
BLI_assert(parent->id.flag & LIB_EMBEDDED_DATA);
- 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(&parent->id);
+ Scene *scene_owner = reinterpret_cast<Scene *>(BKE_id_owner_get(&parent->id));
BLI_assert(scene_owner != nullptr);
BLI_assert(GS(scene_owner->id.name) == ID_SCE);
diff --git a/source/blender/makesrna/intern/rna_path.cc b/source/blender/makesrna/intern/rna_path.cc
index bc77ca3f7d3..6fc1eed7e23 100644
--- a/source/blender/makesrna/intern/rna_path.cc
+++ b/source/blender/makesrna/intern/rna_path.cc
@@ -16,6 +16,7 @@
#include "BKE_idprop.h"
#include "BKE_idtype.h"
+#include "BKE_lib_id.h"
#include "DNA_ID.h" /* For ID properties. */
@@ -940,11 +941,9 @@ ID *RNA_find_real_ID_and_path(ID *id, const char **r_path)
}
}
- if (id_type->owner_get == nullptr) {
- BLI_assert_msg(0, "Missing handling of embedded id type.");
- return id;
- }
- return id_type->owner_get(id);
+ ID *owner_id = BKE_id_owner_get(id);
+ BLI_assert_msg(owner_id != nullptr, "Missing handling of embedded id type.");
+ return (owner_id != nullptr) ? owner_id : id;
}
static char *rna_prepend_real_ID_path(Main * /*bmain*/, ID *id, char *path, ID **r_real_id)
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 61eb2a11c02..e2b3276c45f 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -1482,8 +1482,7 @@ static void rna_ImageFormatSettings_color_management_set(PointerRNA *ptr, int va
ID *owner_id = ptr->owner_id;
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(owner_id);
+ owner_id = BKE_id_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);