Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_outliner/outliner_collections.c
| Context not available. | |||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "MEM_guardedalloc.h" | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| Context not available. | |||||
| struct CollectionDeleteData { | struct CollectionDeleteData { | ||||
| Scene *scene; | Scene *scene; | ||||
| SpaceOops *soops; | SpaceOops *soops; | ||||
| ListBase collections_to_delete; | |||||
| }; | }; | ||||
| static TreeTraversalAction collection_delete_cb(TreeElement *te, void *customdata) | static TreeTraversalAction collection_find_data_to_delete(TreeElement *te, void *customdata) | ||||
| { | { | ||||
| struct CollectionDeleteData *data = customdata; | struct CollectionDeleteData *data = customdata; | ||||
| SceneCollection *scene_collection = outliner_scene_collection_from_tree_element(te); | SceneCollection *scene_collection = outliner_scene_collection_from_tree_element(te); | ||||
| Context not available. | |||||
| /* skip - showing warning/error message might be missleading | /* skip - showing warning/error message might be missleading | ||||
| * when deleting multiple collections, so just do nothing */ | * when deleting multiple collections, so just do nothing */ | ||||
| } | } | ||||
| else { | else if (BLI_findptr(&data->collections_to_delete, scene_collection, offsetof(LinkData, data)) == NULL) { | ||||
| BKE_collection_remove(data->scene, scene_collection); | |||||
| LinkData *scene_collection_link = MEM_mallocN(sizeof(LinkData), __func__); | |||||
| scene_collection_link->data = scene_collection; | |||||
| BLI_addtail(&(data->collections_to_delete), scene_collection_link); | |||||
dfelinto: Instead do:
```
BLI_addtail(&(data->collections_to_delete), BLI_genericNodeN… | |||||
| } | } | ||||
| return TRAVERSE_CONTINUE; | return TRAVERSE_CONTINUE; | ||||
| } | } | ||||
| static void collection_data_delete(struct CollectionDeleteData *data) | |||||
| { | |||||
| Scene *scene = data->scene; | |||||
| LinkData *link, *next; | |||||
| link = data->collections_to_delete.first; | |||||
| while (link) { | |||||
| next = link->next; | |||||
| BKE_collection_remove(data->scene, (SceneCollection*)link->data); | |||||
dfelintoUnsubmitted Not Done Inline Actions- BKE_collection_remove(data->scene, (SceneCollection*)link->data); + BKE_collection_remove(&data->scene->id, (SceneCollection*)link->data); Nothing wrong with the original patch, but the code in blender2.8 changed since you did this. dfelinto: ```
- BKE_collection_remove(data->scene, (SceneCollection*)link->data);
+ BKE_collection_remove… | |||||
| link = next; | |||||
| } | |||||
dfelintoUnsubmitted Not Done Inline ActionsThere is no need for this convoluted next = link->next. We do this only when we need to remove elements of the list while iterating over it. dfelinto: There is no need for this convoluted next = link->next. We do this only when we need to remove… | |||||
| BLI_freelistN(&data->collections_to_delete); | |||||
| } | |||||
| static int collection_delete_exec(bContext *C, wmOperator *UNUSED(op)) | static int collection_delete_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SpaceOops *soops = CTX_wm_space_outliner(C); | SpaceOops *soops = CTX_wm_space_outliner(C); | ||||
| struct CollectionDeleteData data = {.scene = scene, .soops = soops}; | struct CollectionDeleteData data = { .scene = scene,.soops = soops, { NULL, NULL } }; | ||||
dfelintoUnsubmitted Not Done Inline Actions- struct CollectionDeleteData data = { .scene = scene,.soops = soops, { NULL, NULL } };
+ struct CollectionDeleteData data = {
+ .scene = scene,
+ .soops = soops,
+ .collections_to_delete = { NULL, NULL },
+};It's actually ok to keep them inline, but use named arguments to initialize the struct. dfelinto: ```
- struct CollectionDeleteData data = { .scene = scene,.soops = soops, { NULL, NULL } };
+… | |||||
| TODO_LAYER_OVERRIDE; /* handle overrides */ | TODO_LAYER_OVERRIDE; /* handle overrides */ | ||||
| outliner_tree_traverse(soops, &soops->tree, 0, TSE_SELECTED, collection_delete_cb, &data); | |||||
| // we first walk over and find the SceneCollections we actually want to delete, *ignoring duplicates* | |||||
dfelintoUnsubmitted Not Done Inline Actions- // we first walk over and find the SceneCollections we actually want to delete, *ignoring duplicates* + /* We first walk over and find the SceneCollections we actually want to delete (ignoring duplicates). */ dfelinto: ```
- // we first walk over and find the SceneCollections we actually want to delete, *ignoring… | |||||
| outliner_tree_traverse(soops, &soops->tree, 0, TSE_SELECTED, collection_find_data_to_delete, &data); | |||||
| // now actually delete those bad dudes... | |||||
dfelintoUnsubmitted Not Done Inline Actions- // now actually delete those bad dudes... + /* Effectively delete the collections. */ dfelinto: ```
- // now actually delete those bad dudes...
+ /* Effectively delete the collections. */… | |||||
| collection_data_delete(&data); | |||||
| DEG_relations_tag_update(CTX_data_main(C)); | DEG_relations_tag_update(CTX_data_main(C)); | ||||
| Context not available. | |||||
Instead do:
And adapt the rest of the code accordingly.