[Bf-blender-cvs] [512fb74980] blender2.8: Outliner: Make deleting collections from "All Collections" mode work

Julian Eisel noreply at git.blender.org
Tue Feb 28 22:19:35 CET 2017


Commit: 512fb74980c5ebc70fe625654b104a5c6e6b498c
Author: Julian Eisel
Date:   Tue Feb 28 22:18:11 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB512fb74980c5ebc70fe625654b104a5c6e6b498c

Outliner: Make deleting collections from "All Collections" mode work

===================================================================

M	source/blender/editors/space_outliner/outliner_collections.c
M	source/blender/editors/space_outliner/outliner_tree.c

===================================================================

diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 889fb6dd36..39bb151f3c 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -294,12 +294,20 @@ static TreeTraversalReturn collection_delete_cb(TreeElement *te, void *customdat
 {
 	struct CollectionDeleteData *data = customdata;
 	TreeStoreElem *tselem = TREESTORE(te);
-	LayerCollection *lc = te->directdata;
+	SceneCollection *scene_collection;
 
-	if (tselem->type != TSE_LAYER_COLLECTION) {
-		/* skip */
+	if (tselem->type == TSE_LAYER_COLLECTION) {
+		LayerCollection *lc = te->directdata;
+		scene_collection = lc->scene_collection;
 	}
-	else if (lc->scene_collection == BKE_collection_master(data->scene)) {
+	else if (tselem->type == TSE_SCENE_COLLECTION) {
+		scene_collection = te->directdata;
+	}
+	else {
+		return TRAVERSE_SKIP_CHILDS;
+	}
+
+	if (scene_collection == BKE_collection_master(data->scene)) {
 		/* skip - showing warning/error message might be missleading
 		 * when deleting multiple collections, so just do nothing */
 	}
@@ -311,7 +319,7 @@ static TreeTraversalReturn collection_delete_cb(TreeElement *te, void *customdat
 		 * This works as workaround, but having a proper way to find the TreeStoreElem for a recreated
 		 * TreeElement would be better. It could use an idname or the directdata pointer for that. */
 		outliner_remove_treestore_element(data->soops, tselem);
-		BKE_collection_remove(data->scene, lc->scene_collection);
+		BKE_collection_remove(data->scene, scene_collection);
 	}
 
 	return TRAVERSE_CONTINUE;
@@ -323,7 +331,7 @@ static int collection_delete_exec(bContext *C, wmOperator *UNUSED(op))
 	SpaceOops *soops = CTX_wm_space_outliner(C);
 	struct CollectionDeleteData data = {.scene = scene, .soops = soops};
 
-	TODO_LAYER_OVERRIDE; /* handle operators */
+	TODO_LAYER_OVERRIDE; /* handle overrides */
 	outliner_tree_traverse(soops, &soops->tree, 0, TSE_SELECTED, collection_delete_cb, &data);
 
 	WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 1ac843660f..8a024e0cc8 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1330,10 +1330,12 @@ static void outliner_add_scene_collection_init(TreeElement *te, SceneCollection
 }
 
 static void outliner_add_scene_collections_recursive(SpaceOops *soops, ListBase *tree, Scene *scene,
-                                                     ListBase *scene_collections, TreeElement *parent_ten)
+                                                     ListBase *scene_collections, TreeElement *parent_ten,
+                                                     int *io_collection_counter)
 {
 	for (SceneCollection *collection = scene_collections->first; collection; collection = collection->next) {
-		TreeElement *ten = outliner_add_element(soops, tree, scene, parent_ten, TSE_SCENE_COLLECTION, 0);
+		TreeElement *ten = outliner_add_element(soops, tree, scene, parent_ten, TSE_SCENE_COLLECTION,
+		                                        (*io_collection_counter)++);
 
 		outliner_add_scene_collection_init(ten, collection);
 		for (LinkData *link = collection->objects.first; link; link = link->next) {
@@ -1341,16 +1343,20 @@ static void outliner_add_scene_collections_recursive(SpaceOops *soops, ListBase
 		}
 		outliner_make_hierarchy(&ten->subtree);
 
-		outliner_add_scene_collections_recursive(soops, &ten->subtree, scene, &collection->scene_collections, ten);
+		outliner_add_scene_collections_recursive(soops, &ten->subtree, scene, &collection->scene_collections, ten,
+		                                         io_collection_counter);
 	}
 }
 static void outliner_add_collections_master(SpaceOops *soops, Scene *scene)
 {
 	SceneCollection *master = BKE_collection_master(scene);
-	TreeElement *ten = outliner_add_element(soops, &soops->tree, scene, NULL, TSE_SCENE_COLLECTION, 0);
+	int collection_counter = 0;
+	TreeElement *ten = outliner_add_element(soops, &soops->tree, scene, NULL, TSE_SCENE_COLLECTION,
+	                                        collection_counter++);
 
 	outliner_add_scene_collection_init(ten, master);
-	outliner_add_scene_collections_recursive(soops, &ten->subtree, scene, &master->scene_collections, ten);
+	outliner_add_scene_collections_recursive(soops, &ten->subtree, scene, &master->scene_collections, ten,
+	                                         &collection_counter);
 }
 
 /* ======================================================= */




More information about the Bf-blender-cvs mailing list