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>2022-05-19 17:48:45 +0300
committerBastien Montagne <bastien@blender.org>2022-05-19 17:51:24 +0300
commit2d5b91d6a0f7470dd475721ea038c061513090d7 (patch)
treefee6e0827014017ebad2b1fb81a1c56110d25dad /source/blender/editors
parentf8ebb0e1d556244d8e79c2efa105df9df909e3f8 (diff)
Fix (studio-reported) more possibilities to edit content of linked/override collections.
Existing code for the `Move` operator, and some `Collections` panel operations (Object properties) was absolutely not override-safe, and sometimes not even linked-data safe.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/object/object_collection.c18
-rw-r--r--source/blender/editors/object/object_edit.c5
2 files changed, 21 insertions, 2 deletions
diff --git a/source/blender/editors/object/object_collection.c b/source/blender/editors/object/object_collection.c
index 054c9e1de46..39951c2ab6e 100644
--- a/source/blender/editors/object/object_collection.c
+++ b/source/blender/editors/object/object_collection.c
@@ -526,7 +526,7 @@ void OBJECT_OT_collection_link(wmOperatorType *ot)
ot->prop = prop;
}
-static int collection_remove_exec(bContext *C, wmOperator *UNUSED(op))
+static int collection_remove_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Object *ob = ED_object_context(C);
@@ -535,6 +535,12 @@ static int collection_remove_exec(bContext *C, wmOperator *UNUSED(op))
if (!ob || !collection) {
return OPERATOR_CANCELLED;
}
+ if (ID_IS_LINKED(collection) || ID_IS_OVERRIDE_LIBRARY(collection)) {
+ BKE_report(op->reports,
+ RPT_ERROR,
+ "Cannot remove an object from a linked or library override collection");
+ return OPERATOR_CANCELLED;
+ }
BKE_collection_object_remove(bmain, collection, ob, false);
@@ -561,7 +567,7 @@ void OBJECT_OT_collection_remove(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static int collection_unlink_exec(bContext *C, wmOperator *UNUSED(op))
+static int collection_unlink_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Collection *collection = CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data;
@@ -569,6 +575,14 @@ static int collection_unlink_exec(bContext *C, wmOperator *UNUSED(op))
if (!collection) {
return OPERATOR_CANCELLED;
}
+ if (ID_IS_OVERRIDE_LIBRARY(collection) &&
+ collection->id.override_library->hierarchy_root != &collection->id) {
+ BKE_report(op->reports,
+ RPT_ERROR,
+ "Cannot unlink a library override collection which is not the root of its override "
+ "hierarchy");
+ return OPERATOR_CANCELLED;
+ }
BKE_id_delete(bmain, collection);
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index cb0e76c11e4..ff25859b56b 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -1811,6 +1811,11 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ if (ID_IS_OVERRIDE_LIBRARY(collection)) {
+ BKE_report(op->reports, RPT_ERROR, "Cannot add objects to a library override collection");
+ return OPERATOR_CANCELLED;
+ }
+
ListBase objects = selected_objects_get(C);
if (is_new) {