diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2015-08-14 16:49:14 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2015-08-14 16:54:58 +0300 |
commit | 5fafd493c2e871e9ce20ab31aea79d332b3bdfb6 (patch) | |
tree | b7ef45a1477ca1c5256b6e2517940cb882c4a3d7 | |
parent | a662980f31168f3d38e0475ad48025d4efa8d4e6 (diff) |
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
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 11 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tools.c | 27 |
4 files changed, 32 insertions, 12 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index c8f123992a1..6ffe005ca1a 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -105,7 +105,7 @@ bScreen *ED_screen_add(struct wmWindow *win, struct Scene *scene, const char *na void ED_screen_set(struct bContext *C, struct bScreen *sc); void ED_screen_delete(struct bContext *C, struct bScreen *sc); void ED_screen_set_scene(struct bContext *C, struct bScreen *screen, struct Scene *scene); -void ED_screen_delete_scene(struct bContext *C, struct Scene *scene); +bool ED_screen_delete_scene(struct bContext *C, struct Scene *scene); void ED_screen_set_subwinactive(struct bContext *C, struct wmEvent *event); void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen); void ED_screen_animation_timer(struct bContext *C, int redraws, int refresh, int sync, int enable); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index ae0d2619645..b714eb00169 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1707,8 +1707,11 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) } -/* only call outside of area/region loops */ -void ED_screen_delete_scene(bContext *C, Scene *scene) +/** + * \note Only call outside of area/region loops + * \return true if successful + */ +bool ED_screen_delete_scene(bContext *C, Scene *scene) { Main *bmain = CTX_data_main(C); Scene *newscene; @@ -1718,11 +1721,13 @@ void ED_screen_delete_scene(bContext *C, Scene *scene) else if (scene->id.next) newscene = scene->id.next; else - return; + return false; ED_screen_set_scene(C, CTX_wm_screen(C), newscene); BKE_scene_unlink(bmain, scene, newscene); + + return true; } ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 1d31cc04e38..1309fb103e9 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3986,7 +3986,9 @@ static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - ED_screen_delete_scene(C, scene); + if (ED_screen_delete_scene(C, scene) == false) { + return OPERATOR_CANCELLED; + } if (G.debug & G_DEBUG) printf("scene delete %p\n", scene); 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); |