From 5fafd493c2e871e9ce20ab31aea79d332b3bdfb6 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Fri, 14 Aug 2015 15:49:14 +0200 Subject: Fix unnecessarily added undo steps when deleting only scene Steps to reproduce were: startup.blend, move any object, delete active scene (nothing happens), undo (nothing happens), second undo is needed to revert object transformation --- .../editors/space_outliner/outliner_tools.c | 27 ++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'source/blender/editors/space_outliner') diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 27100aac8cf..50171d7f032 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -273,29 +273,40 @@ static EnumPropertyItem prop_scene_op_types[] = { {0, NULL, 0, NULL, NULL} }; -static void outliner_do_scene_operation( +static bool outliner_do_scene_operation( bContext *C, eOutliner_PropSceneOps event, ListBase *lb, - void (*operation_cb)(bContext *, eOutliner_PropSceneOps, TreeElement *, TreeStoreElem *)) + bool (*operation_cb)(bContext *, eOutliner_PropSceneOps, TreeElement *, TreeStoreElem *)) { TreeElement *te; TreeStoreElem *tselem; + bool success = false; for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { - operation_cb(C, event, te, tselem); + if (operation_cb(C, event, te, tselem)) { + success = true; + } } } + + return success; } -static void scene_cb(bContext *C, eOutliner_PropSceneOps event, TreeElement *UNUSED(te), TreeStoreElem *tselem) +static bool scene_cb(bContext *C, eOutliner_PropSceneOps event, TreeElement *UNUSED(te), TreeStoreElem *tselem) { Scene *scene = (Scene *)tselem->id; if (event == OL_SCENE_OP_DELETE) { - ED_screen_delete_scene(C, scene); - WM_event_add_notifier(C, NC_SCENE | NA_REMOVED, scene); + if (ED_screen_delete_scene(C, scene)) { + WM_event_add_notifier(C, NC_SCENE | NA_REMOVED, scene); + } + else { + return false; + } } + + return true; } static int outliner_scene_operation_exec(bContext *C, wmOperator *op) @@ -303,7 +314,9 @@ static int outliner_scene_operation_exec(bContext *C, wmOperator *op) SpaceOops *soops = CTX_wm_space_outliner(C); const eOutliner_PropSceneOps event = RNA_enum_get(op->ptr, "type"); - outliner_do_scene_operation(C, event, &soops->tree, scene_cb); + if (outliner_do_scene_operation(C, event, &soops->tree, scene_cb) == false) { + return OPERATOR_CANCELLED; + } if (event == OL_SCENE_OP_DELETE) { outliner_cleanup_tree(soops); -- cgit v1.2.3