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 <montagne29@wanadoo.fr>2019-03-12 16:58:33 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-03-12 17:48:24 +0300
commit33dd01fc69d820fedd86d118d5bb01036955380e (patch)
tree7b49c58ddc0c0fd99aecbf63ef7b07cbcbab6183 /source/blender/editors/space_outliner
parent913b1fd29a8cb721c4cb001a10872e7c09e6bbfe (diff)
Fix (unreported) duplicated collection from linked scene would be parented to that scene.
In other words, Duplicate Collection could link local ID into a linked one... Nasty. ;) Add checks that found parent is not a linked data-block (and try to find a fall-back one if this is the case).
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index a95d292ec74..efb28124e57 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -459,11 +459,33 @@ static int collection_duplicate_exec(bContext *C, wmOperator *op)
Collection *collection = outliner_collection_from_tree_element(te);
Collection *parent = (te->parent) ? outliner_collection_from_tree_element(te->parent) : NULL;
+ /* We are allowed to duplicated linked collections (they will become local IDs then),
+ * but we should not allow its parent to be a linked ID, ever.
+ * This can happen when a whole scene is linked e.g. */
+ if (parent != NULL && ID_IS_LINKED(parent)) {
+ Scene *scene = CTX_data_scene(C);
+ parent = ID_IS_LINKED(scene) ? NULL : BKE_collection_master(scene);
+ }
+ else if (parent != NULL && (parent->flag & COLLECTION_IS_MASTER) != 0) {
+ Scene *scene = BKE_collection_master_scene_search(bmain, parent);
+ BLI_assert(scene != NULL);
+ if (ID_IS_LINKED(scene)) {
+ scene = CTX_data_scene(C);
+ parent = ID_IS_LINKED(scene) ? NULL : BKE_collection_master(scene);
+ }
+ }
+
if (collection->flag & COLLECTION_IS_MASTER) {
BKE_report(op->reports, RPT_ERROR, "Can't duplicate the master collection");
return OPERATOR_CANCELLED;
}
+ if (parent == NULL) {
+ BKE_report(op->reports, RPT_WARNING,
+ "Could not find a valid parent collection for the new duplicate, "
+ "it won't be linked to any view layer");
+ }
+
switch (soops->outlinevis) {
case SO_SCENES:
case SO_VIEW_LAYER: