[Bf-blender-cvs] [9778b0a5bc2] master: Fix T62488: Can delete collection from indirect linked library.
Bastien Montagne
noreply at git.blender.org
Tue Mar 12 15:48:52 CET 2019
Commit: 9778b0a5bc24b82b9ea32a7a28c564eec58ebc67
Author: Bastien Montagne
Date: Tue Mar 12 15:37:09 2019 +0100
Branches: master
https://developer.blender.org/rB9778b0a5bc24b82b9ea32a7a28c564eec58ebc67
Fix T62488: Can delete collection from indirect linked library.
Same issue as with previous commits for other Collection Outlier's
operations, checks are always different though...
===================================================================
M source/blender/editors/space_outliner/outliner_collections.c
===================================================================
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 04104aa0e4c..b79f93781d2 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -290,7 +290,39 @@ static int collection_delete_exec(bContext *C, wmOperator *op)
/* Test in case collection got deleted as part of another one. */
if (BLI_findindex(&bmain->collections, collection) != -1) {
- BKE_collection_delete(bmain, collection, hierarchy);
+ /* We cannot allow to delete collections that are indirectly linked, or that are used by (linked to...)
+ * other linked scene/collection. */
+ bool skip = false;
+ if (ID_IS_LINKED(collection)) {
+ if (collection->id.tag & LIB_TAG_INDIRECT) {
+ skip = true;
+ }
+ else {
+ for (CollectionParent *cparent = collection->parents.first; cparent; cparent = cparent->next) {
+ Collection *parent = cparent->collection;
+ if (ID_IS_LINKED(parent)) {
+ skip = true;
+ break;
+ }
+ else if (parent->flag & COLLECTION_IS_MASTER) {
+ Scene *parent_scene = BKE_collection_master_scene_search(bmain, parent);
+ if (ID_IS_LINKED(parent_scene)) {
+ skip = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (!skip) {
+ BKE_collection_delete(bmain, collection, hierarchy);
+ }
+ else {
+ BKE_reportf(op->reports, RPT_WARNING,
+ "Cannot delete linked collection '%s', it is used by other linked scenes/collections",
+ collection->id.name + 2);
+ }
}
}
More information about the Bf-blender-cvs
mailing list