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
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-09-05 21:43:52 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-09-05 22:31:01 +0300
commit5f4caa8c4fc393e6519b810fc095b4c339266251 (patch)
tree76c0db78a2f196f5b0f92ba507ac38fd3055d0d8 /source
parent8622849beb964536d39ca2da8a2a0e4db978502f (diff)
LibOverride: add a generic macro to check whetehr an ID is overridable.
...and use it in code generating library overrides.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_templates.c16
-rw-r--r--source/blender/editors/object/object_relations.c15
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c2
-rw-r--r--source/blender/makesdna/DNA_ID.h7
-rw-r--r--source/blender/makesrna/intern/rna_ID.c2
5 files changed, 32 insertions, 10 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 5a333a5fa27..62eebfdd3c7 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -516,13 +516,15 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
if (id) {
Main *bmain = CTX_data_main(C);
if (BKE_override_library_is_enabled() && CTX_wm_window(C)->eventstate->shift) {
- /* Only remap that specific ID usage to overriding local data-block. */
- ID *override_id = BKE_override_library_create_from_id(bmain, id, false);
- if (override_id != NULL) {
- BKE_main_id_clear_newpoins(bmain);
-
- /* Assign new pointer, takes care of updates/notifiers */
- RNA_id_pointer_create(override_id, &idptr);
+ if (ID_IS_OVERRIDABLE_LIBRARY(id)) {
+ /* Only remap that specific ID usage to overriding local data-block. */
+ ID *override_id = BKE_override_library_create_from_id(bmain, id, false);
+ if (override_id != NULL) {
+ BKE_main_id_clear_newpoins(bmain);
+
+ /* Assign new pointer, takes care of updates/notifiers */
+ RNA_id_pointer_create(override_id, &idptr);
+ }
}
}
else {
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 60a2b9cca0d..0d20a07dcee 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2426,6 +2426,14 @@ static int make_override_library_exec(bContext *C, wmOperator *op)
if (!ID_IS_LINKED(obact) && obact->instance_collection != NULL &&
ID_IS_LINKED(obact->instance_collection)) {
+ if (!ID_IS_OVERRIDABLE_LIBRARY(obact->instance_collection)) {
+ BKE_reportf(op->reports,
+ RPT_ERROR_INVALID_INPUT,
+ "Collection '%s' (instantiated by the active object) is not overridable",
+ obact->instance_collection->id.name + 2);
+ return OPERATOR_CANCELLED;
+ }
+
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
Object *obcollection = obact;
@@ -2507,6 +2515,13 @@ static int make_override_library_exec(bContext *C, wmOperator *op)
BKE_main_id_clear_newpoins(bmain);
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
}
+ else if (!ID_IS_OVERRIDABLE_LIBRARY(obact)) {
+ BKE_reportf(op->reports,
+ RPT_ERROR_INVALID_INPUT,
+ "Active object '%s' is not overridable",
+ obact->id.name + 2);
+ return OPERATOR_CANCELLED;
+ }
/* Else, poll func ensures us that ID_IS_LINKED(obact) is true. */
else if (obact->type == OB_ARMATURE) {
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 91d7f0f9374..219943d08a6 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -713,7 +713,7 @@ static void id_override_library_cb(bContext *C,
TreeStoreElem *tselem,
void *UNUSED(user_data))
{
- if (ID_IS_LINKED(tselem->id) && (tselem->id->tag & LIB_TAG_EXTERN)) {
+ if (ID_IS_OVERRIDABLE_LIBRARY(tselem->id)) {
Main *bmain = CTX_data_main(C);
/* For now, remapp all local usages of linked ID to local override one here. */
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, true);
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index ed7416e06c9..a1bc71ade62 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -432,10 +432,15 @@ typedef enum ID_Type {
#define ID_BLEND_PATH_FROM_GLOBAL(_id) \
((_id)->lib ? (_id)->lib->filepath : BKE_main_blendfile_path_from_global())
-#define ID_MISSING(_id) (((_id)->tag & LIB_TAG_MISSING) != 0)
+#define ID_MISSING(_id) ((((ID *)(_id))->tag & LIB_TAG_MISSING) != 0)
#define ID_IS_LINKED(_id) (((ID *)(_id))->lib != NULL)
+/* Note that this is a fairly high-level check, should be used at user interaction level, not in
+ * BKE_library_override typically (especially due to the check on LIB_TAG_EXTERN). */
+#define ID_IS_OVERRIDABLE_LIBRARY(_id) \
+ (ID_IS_LINKED(_id) && !ID_MISSING(_id) && (((ID *)(_id))->tag & LIB_TAG_EXTERN) != 0)
+
#define ID_IS_OVERRIDE_LIBRARY(_id) \
(((ID *)(_id))->override_library != NULL && ((ID *)(_id))->override_library->reference != NULL)
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 294fdb2e0d8..49fdf9c67d5 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -493,7 +493,7 @@ static ID *rna_ID_copy(ID *id, Main *bmain)
static ID *rna_ID_override_create(ID *id, Main *bmain, bool remap_local_usages)
{
- if (!BKE_override_library_is_enabled() || id->lib == NULL) {
+ if (!BKE_override_library_is_enabled() || !ID_IS_OVERRIDABLE_LIBRARY(id)) {
return NULL;
}