Fix #109802: Outliner "Blender File" view cant delete scene

`outliner_do_scene_operation` wasnt recursive, so it only acted on the
top-level `TreeElement` (which was fine for Scenes view, but failed in
`Blender File` view).

Now use an iterator that handles open subhierarchies as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/109810
This commit is contained in:
Philipp Oeser
2023-07-11 16:31:01 +02:00
committed by Philipp Oeser
parent 087612c042
commit 300cfecc46

View File

@@ -687,20 +687,22 @@ static const EnumPropertyItem prop_scene_op_types[] = {
static bool outliner_do_scene_operation(
bContext *C,
SpaceOutliner *space_outliner,
eOutliner_PropSceneOps event,
ListBase *lb,
bool (*operation_fn)(bContext *, eOutliner_PropSceneOps, TreeElement *, TreeStoreElem *))
{
bool success = false;
LISTBASE_FOREACH (TreeElement *, te, lb) {
tree_iterator::all_open(*space_outliner, [&](TreeElement *te) {
TreeStoreElem *tselem = TREESTORE(te);
if (tselem->flag & TSE_SELECTED) {
if (operation_fn(C, event, te, tselem)) {
success = true;
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_SCE)) {
if (operation_fn(C, event, te, tselem)) {
success = true;
}
}
}
}
});
return success;
}
@@ -729,7 +731,7 @@ static int outliner_scene_operation_exec(bContext *C, wmOperator *op)
SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
const eOutliner_PropSceneOps event = (eOutliner_PropSceneOps)RNA_enum_get(op->ptr, "type");
if (outliner_do_scene_operation(C, event, &space_outliner->tree, scene_fn) == false) {
if (outliner_do_scene_operation(C, space_outliner, event, scene_fn) == false) {
return OPERATOR_CANCELLED;
}