From 69470e36d6b17042260b06f26ca3c2f702747324 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Tue, 15 Nov 2016 11:50:11 +0100 Subject: Implement grouped undo option for operators This option makes an operator to not push a task to the undo stack if the previous stored elemen is the same operator or part of the same undo group. The main usage is for animation, so you can change frames to inspect the poses, and revert the previous pose without having to roll back tons of "change frame" operator, or even see the undo stack full. This complements rB13ee9b8e Design with help by Sergey Sharybin. Reviewers: sergey, mont29 Reviewed By: mont29, sergey Subscribers: pyc0d3r, hjalti, Severin, lowercase, brecht, monio, aligorith, hadrien, jbakker Differential Revision: https://developer.blender.org/D2330 --- source/blender/windowmanager/intern/wm_event_system.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/windowmanager/intern') diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index dc34e8015c9..ad8a67027c0 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -730,6 +730,8 @@ static void wm_operator_finished(bContext *C, wmOperator *op, const bool repeat) if (wm->op_undo_depth == 0) if (op->type->flag & OPTYPE_UNDO) ED_undo_push_op(C, op); + else if (op->type->flag & OPTYPE_UNDO_GROUPED) + ED_undo_grouped_push_op(C, op); if (repeat == 0) { if (G.debug & G_DEBUG_WM) { @@ -1857,6 +1859,8 @@ static int wm_handler_fileselect_do(bContext *C, ListBase *handlers, wmEventHand if (CTX_wm_manager(C) == wm && wm->op_undo_depth == 0) if (handler->op->type->flag & OPTYPE_UNDO) ED_undo_push_op(C, handler->op); + else if (handler->op->type->flag & OPTYPE_UNDO_GROUPED) + ED_undo_grouped_push_op(C, handler->op); if (handler->op->reports->list.first) { -- cgit v1.2.3 From a828818d59f0f8ea41900a12db703ba3fae075a7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 15 Nov 2016 16:01:21 +0100 Subject: Cleanup: More explicit parentheses --- source/blender/windowmanager/intern/wm_event_system.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source/blender/windowmanager/intern') diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index ad8a67027c0..d2b0acd836b 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -727,12 +727,13 @@ static void wm_operator_finished(bContext *C, wmOperator *op, const bool repeat) /* we don't want to do undo pushes for operators that are being * called from operators that already do an undo push. usually * this will happen for python operators that call C operators */ - if (wm->op_undo_depth == 0) + if (wm->op_undo_depth == 0) { if (op->type->flag & OPTYPE_UNDO) ED_undo_push_op(C, op); else if (op->type->flag & OPTYPE_UNDO_GROUPED) ED_undo_grouped_push_op(C, op); - + } + if (repeat == 0) { if (G.debug & G_DEBUG_WM) { char *buf = WM_operator_pystring(C, op, false, true); @@ -1856,11 +1857,12 @@ static int wm_handler_fileselect_do(bContext *C, ListBase *handlers, wmEventHand wm->op_undo_depth--; /* XXX check this carefully, CTX_wm_manager(C) == wm is a bit hackish */ - if (CTX_wm_manager(C) == wm && wm->op_undo_depth == 0) + if (CTX_wm_manager(C) == wm && wm->op_undo_depth == 0) { if (handler->op->type->flag & OPTYPE_UNDO) ED_undo_push_op(C, handler->op); else if (handler->op->type->flag & OPTYPE_UNDO_GROUPED) ED_undo_grouped_push_op(C, handler->op); + } if (handler->op->reports->list.first) { -- cgit v1.2.3 From a90644ed19afbd84d422208772c4a970484b4248 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 18 Nov 2016 18:46:10 +0100 Subject: Minor debug-report tweak to autosave code. Print in cosole a warning when we skip autosave due to runnning modal op. Related to T49974. --- source/blender/windowmanager/intern/wm_files.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/windowmanager/intern') diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index fe257cc4c41..05d63869074 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1144,6 +1144,9 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w for (handler = win->modalhandlers.first; handler; handler = handler->next) { if (handler->op) { wm->autosavetimer = WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, 10.0); + if (G.debug) { + printf("Skipping auto-save, modal operator running, retrying in ten seconds...\n"); + } return; } } @@ -1161,7 +1164,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w ED_editors_flush_edits(C, false); - /* no error reporting to console */ + /* Error reporting into console */ BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL); } /* do timer after file write, just in case file write takes a long time */ -- cgit v1.2.3